[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Slurp weirdness




Hi all.

I have a script which reads from /proc/net/tcp periodically, and noticed
that it worked fine for up to 61 connections (i.e. 63 lines read from
the file), but when the number of connections goes over 63, they are not
reported - only the first 63 lines are read from the file. This was done
roughly as follows:

--------------------
#!/usr/bin/perl
$/ = undef;
open (PROC,'/proc/net/tcp');
@lines = (split("\n",<PROC>));
close PROC;
print scalar(@lines)."\n";
--------------------

When I replaced the slurp with "while (<FH>)" as follows, everything
worked fine, and all connections above 63 were listed:

-----------------------------
#!/usr/bin/perl
open (PROC,'/proc/net/tcp');
while (<PROC>) {
 push(@lines,$_);
}
close PROC;
print scalar(@lines)."\n";
-----------------------------

This is , of course, not true for "real" files. One could expect some
oddities reading from from a /dev file which is constantly changing, but
what surprised me is that the slurp consistently reads only 63 lines
from the file.

Any ideas?

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe