Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Cant help print key word

by aitap (Deacon)
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2016-10-22 11:49 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.