Re: Return text left of first tab
- From: sln@xxxxxxxxxxxxxxx
- Date: Thu, 04 Mar 2010 09:36:19 -0800
On Thu, 04 Mar 2010 08:15:12 -0600, Don Pich <dpich@xxxxxxxxxxxx> wrote:
After the 'my ($line) = $_;' line, I need to eliminate everything after
and including the first tab of a line in Pannaway.txt. Then send what is
left (IP Address column only) into the my@values to convert the dotted
quad ip address into a hex representation of the ip.
An assumption, this regex adds some further qualifying boundry conditions.
If learning regex's, you might want to break down the example
as an exercise.
-sln
use strict;
use warnings;
while (<DATA>)
{
if (/^((?:\d+\.?){4,6})[.:\d]*?\t.*BAS-ADSL/) {
my @ipparts = split('\.', $1);
printf ('%02x'x scalar(@ipparts) ."\n", @ipparts);
}
}
__DATA__
IP Address Name Type MAC Address
Firmware
10.21.65.252.5.4.3 ADMS.01.01 BAS-ADSL24R 00:0A:9F:00:D4:75
10.21.1.2:1280 ADMS.01.01 BAS-ADSL24R 00:0A:9F:00:D4:75
3.2.1.28
10.21.66.252 ADMS.02.01 BAS-ADSL24R 00:0A:9F:00:D4:A5
3.2.1.28
10.21.66.250 ADMS.03.01 BAS-ADSL24R 00:0A:9F:00:D4:C1
3.2.1.28
10.21.66.248 ADMS.04.01 BAS-ADSL24R 00:0A:9F:00:D4:D1
3.2.1.28
10.21.67.252 ADMS.05.01 BAS-ADSL24R 00:0A:9F:00:E5:DA
3.2.1.28
.
- References:
- Re: Return text left of first tab
- From: Jürgen Exner
- Re: Return text left of first tab
- From: Don Pich
- Re: Return text left of first tab
- Prev by Date: Re: Prevent script from adding an extra line at the end of file
- Next by Date: Re: Prevent script from adding an extra line at the end of file
- Previous by thread: Re: Return text left of first tab
- Next by thread: Re: Return text left of first tab
- Index(es):