Footie and PPerl

Matts on 2002-06-08T09:30:34

So yesterday I must have been about the only person in the UK who managed to remain all day without finding out the score (for those of you who live in a cave, England were playing Argentina - old rivals, what with the war and good old Maradona knocking us out of the world cup via a handball a few years back)...

ITV were showing the game in full at 8pm (the game was on live at 12:30, but I was at work). So I had to basically get through the day without anyone telling me the score. People on IRC were warned that I'd be miffed, and my headphones pretty much stayed on the whole day. When I got home my wife was itching to tell me about her day's chenanigans, which of *course* involved some sort of World Cup related incident in town, but I zipped her lips and told her she'd have to wait to tell me after the game.

And what a game.

England played incredibly well, looking tight and like a proper team (this is often quite unusual for our boys). Owen was ablaze in the box, causing serious concern for the Argentinian defence. And Argentina's reputation for being a bit aggressive with their tackling got the better of them, bringing down Owen in the box.

The second half was immensely stressful towards the end of the game, as Argentina piled on every ounce of attack they could muster. But our defence held tight, and we held onto our first victory over Argentina in 22 years. Awesome.

Back in perl-land, PPerl isn't looking too hot at the moment. My re-write seems to mostly work, except the ARGV magic, which looks like this:



# First populate @ARGV from data sent over the socket

# then assign magic if necessary:

if (!@ARGV) { # magic for # *ARGV = \*{ $____self }; *ARGV = *STDIN; }


(the commented out line was an attempt at fixing it, but it too fails the same way).

This works some of the time, but every now and then will give me:

"readline() on closed filehandle ARGV"

(the script doing this just does "print <>;", and the failing test is passed the filename on the command line (i.e. via @ARGV))

Note that this only happens when @ARGV is true (i.e. the above test is false). Which makes it even stranger. I'm not sure how the ARGV magic works internally, or why it would end up closed. Or why the exact same code would work when using Net::Server and not when writing my own daemon. Or why it would only fail sporadically.

Gah. Awful bug to debug. Hints appreciated.


@ARGV

jdavidb on 2002-06-08T14:32:23

I'm probably clueless as to what your intent is, but can you just say:

if (!@ARGV)
{
unshift '-', @ARGV;
}

Wouldn't that accomplish what you want?

Re:@ARGV

Matts on 2002-06-08T18:22:18

Yes and No. The bug is the case where I don't set the ARGV magic, not when I do.

Even if I change the ARGV stuff to the above, it fails periodically.

I'm pretty sure now that it's parent/child management. I'm not very good at all this signals stuff, so I'll have to delve into it more deeply tomorrow.