Scary code of the day

gav on 2004-05-17T15:05:31

sub lock_retrieveFH {
    my $datafile = sprintf ("/usr/bin/unzip -p %s |", FILE);
    open my $pipe, $datafile or die print $!, $/;
    flock($pipe,LOCK_EX);
    return $pipe;
}

*shudder*


"That's not right...that's not even wrong"

kag on 2004-05-17T22:07:01

Do we want to make a list?

1) What is FILE supposed to stringify to? It looks like a filehandle, but that won't give the filename. I'll be generous and assume we have "use constant FILE=>'filename.zip'" in there somewhere.

2) Even assuming FILE stringifies, why sprintf?

3) Locking a pipe? No other process can compete for access. Mistaken attempt to lock the underlying file, or very strange attempt at inter-thread locking?

I really don't want to see the rest of that code.