Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.

Comment on Re: Cant help print key word
Select or Download Code

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 musing on the Monastery: (3)
As of 2015-10-10 06:16 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (254 votes), past polls