in reply to Cant help print key word

Great suggestions have been given. Here's are some other observations/suggestions:

Give the above, consider the following:

use strict; use warnings; my ( @IPS, $IP ); print "Enter name:\n"; my $s = <>; chomp $s; open my $fh, '<', 'routers.txt' or die $!; while ( my $line = <$fh> ) { if ( $line =~ /\b$s\b/ ) { my ($IP) = $line =~ /(\d+\.\d+\.\d+\.\d+)/; push( @IPS, $IP ); } } close $fh; print "$_\n" for @IPS;

Hope this helps!