in reply to Re^2: need to remove the extra line in regular expression
in thread need to remove the extra line in regular expression
my $interface; # declare the variable while (<>) { # if there are non-space symbols on the start of the line, # consider it interface name $interface = $1 if /^([\S]+)/; # $1 means first matched () group of s +ymbols # a group of numeric symbols or dots after "inet addr:" # is considered an IP-address print "$interface => $1\n" if /inet addr:([0-9.]+)/; # use /inet6? addr: ?([0-9a-f.]+)/ if you want to match IPv6-addresse +s }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: need to remove the extra line in regular expression
by laksh (Novice) on Aug 23, 2012 at 07:07 UTC | |
by aitap (Curate) on Aug 23, 2012 at 07:21 UTC | |
by laksh (Novice) on Aug 23, 2012 at 08:17 UTC | |
by aitap (Curate) on Aug 23, 2012 at 08:51 UTC | |
by laksh (Novice) on Aug 23, 2012 at 11:05 UTC | |
| |
by laksh (Novice) on Aug 23, 2012 at 11:59 UTC | |
|