Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Cant help print key word

by aitap (Curate)
on Aug 28, 2012 at 15:31 UTC ( #990266=note: print w/replies, xml ) Need Help??

in reply to Cant help print key word

Well, firstly you read and print the entire file and then try to search in the remaining parts of the file (i.e nowhere). If you really want to work this way, you should seek to the beginning of the file.

Also, your $IP variable is declared inly inside the while loop. Declare it earlier (outside the loop) or print something from @IPS instead.

Also, you need another syntax for your matching:

($IP) = $line =~ /(\d+\.\d+\.\d+\.\d+)/;
Pattern matching returns an array, and you should assign an array (anonymous array is fine) if you want to get what matched (not the count of matches = array in scalar context).

Sorry if my advice was wrong.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990266]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-03-20 03:09 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (247 votes). Check out past polls.