Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Array size issue

by hmb104 (Sexton)
on Oct 15, 2012 at 19:03 UTC ( #999158=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Array size issue
in thread Array size issue

I apologize for not being clear and I do appreciate all the valuable input I get from this community.

Without the print statement I will not be able to debug my code. I want to make sure my array is carrying the proper line/data before attempting to process it. This is what I got after reading all the comments. I think I'm missing a small piece and I can't figure it out.

open my $tailf, "tail -f $logFile |" or die; while (<$tailf>) { chomp; my $line = $_; if($line =~ m/ on $ipaddress/) { if (scalar(@matches) <= 2){ push(@matches, $line); } else { last; } } } foreach $line (@matches){ print "$line\n"; } close $tailf;


Comment on Re^4: Array size issue
Download Code
Re^5: Array size issue
by blue_cowdawg (Prior) on Oct 15, 2012 at 20:43 UTC

    myself I'd rewrite two of your "ifs."

    next unless ($line =~ m@on $ipaddress@); last if scalar(@matches) >= 2;
    At least to my eye that's more readable.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-08-01 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (51 votes), past polls