Did you copy and paste that code, or attempt to retype it?
$ perl temp.pl
String found where operator expected at temp.pl line 13, near "d 'Time
+out on read'"
(Do you need to predeclare d?)
syntax error at temp.pl line 13, near "d 'Timeout on read'"
Missing right curly or square bracket at temp.pl line 16, at end of li
+ne
syntax error at temp.pl line 16, at EOF
Execution of temp.pl aborted due to compilation errors.
update:
Ah, now (with your sub d) I get 100% CPU utilization, for much longer
than a second,
which I guess is probably similar to what you're getting, and which
is presumably not what you want. So yeah, it appears the problem is
not just something weird with your local setup, which is what I was
trying to confirm. I threw in an extra warn and confirmed that
$paddr is always undef, but I imagine what you're trying to do is
limit execution time when there's no connection. Hmmm...
select undef,undef,undef,$delay can measure fractional
parts of a second, but I don't know how small its resolution goes.
That would also stop you from consuming 100% CPU, though: just
loop through $n tries with $totaltimelimit/$n delay each time.
Would that work?
$ perl -v
This is perl, v5.8.7 built for i386-freebsd-64int
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Perl may be copied only under the terms of either the Artistic License
+ or the
GNU General Public License, which may be found in the Perl 5 source ki
+t.
Complete documentation for Perl, including FAQ lists, should be found
+on
this system using `man perl' or `perldoc perl'. If you have access to
+ the
Internet, point your browser at http://www.perl.org/, the Perl Home Pa
+ge.
I wanted to help you out by testing your code on another FreeBSD
system, but I think there's more wrong than $SIG{ALRM} only.
Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. Why, I've got so much sanity it's driving me crazy.
|