Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Array size issue

by smile4me (Beadle)
on Oct 15, 2012 at 22:25 UTC ( #999194=note: print w/replies, xml ) Need Help??


in reply to Array size issue

Is there a reason you are using "tail -f" in your file handle, as opposed to "tail -n 10" or similar. In my system, the script hangs waiting for additional input to the file. Here's an alternative idea for you to consider:

my @list; my $file = q[/path/to/some/file]; my $regex = qr[your pattern]; open my $fh, "tail $file |" or die; while (<$fh>) { chomp; say "testing: $_"; push @list, $_ if ( $_ =~ $regex); last if (@list >= 2); } local $"="\n"; say "found: @list";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2021-06-12 18:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (53 votes). Check out past polls.

    Notices?