zakishah has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i want to display specific ip address that is stored in txt file near keyword "a.AS1", which i am taking from user input but my code is not working.
open FILE , "routers.txt" or die $!; while (<FILE>) { print "$_\n"; } print " Enter name"; $s=<>; chomp($s); while(my $line = <FILE>) { #if(/\b$s\b/){ if(/\b$s\b/){ my $IP = $line =~ /\d+\.\d+\.\d+\.\d+/; push(@IPS, $IP); } } #print "hei"; print $IP;
text file contents are here
a.AS1 10.0.0.128 b.AS1 10.0.0.129 c.AS1 10.0.0.130 d.AS1 10.0.0.131 e.AS1 10.0.0.132
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cant help print key word
by marto (Cardinal) on Aug 28, 2012 at 15:32 UTC | |
|
Re: Cant help print key word
by Kenosis (Priest) on Aug 28, 2012 at 15:53 UTC | |
|
Re: Cant help print key word
by aitap (Curate) on Aug 28, 2012 at 15:31 UTC | |
|
Re: Cant help print key word
by philiprbrenan (Monk) on Aug 28, 2012 at 15:31 UTC |