in reply to Use of uninitialized value in numeric gt (>)

First of all: don't do my $foo if $cond; — that's going to surprise you when the condition is false, because my has both compile-time and runtime implications, but the conditional is suppressing the runtime effect.

In this particular case, you don't need an if either — a condition returns a boolean value. So you can just say

my $offline = ( -s 'online.flg' ) > 0;

and later do something like if( $offline ) just fine.

Actually, you don't even need to have the comparison, because if -s returns 0, that's false, and if it returns a value greater than zero, that is interpreted as true. You could just say

my $offline = -s 'online.flg';

and using $offline as a boolean would do the right thing.

Finally, all that said and done — I can't reproduce your problem with an existing file. -s returns undef for non-existent ones, though. Is that the source of your problem?

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: Use of uninitialized value in numeric gt (>)
by hv (Prior) on Aug 12, 2004 at 11:49 UTC
    Finally, all that said and done — I can't reproduce your problem ...

    Not surprising: the OP's warning specifically says numeric gt (>), not string gt. I suspect that the warning is coming from a different line of code.

    Hugo