in reply to Re: Use of uninitialized value
in thread Use of uninitialized value

I have a similar question. I have tried my $filesize = 0; and  my $filesize = -s $$file; and I am getting the same warning only when the file size is 0. I have searched but I have not found anything useful. Use of uninitialized value $filesize in numeric ne (!=) Can you please help?
$output_file = 'output_file'; backup_the_data(\$output_file); sub backup_the_data { my ($file) = @_; my $filesize = 0; # my $filesize = -s $$file; $filesize = -s $$file; if ($filesize != 0){ copy($$file, $$file . '_backup'); } }

Replies are listed 'Best First'.
Re^3: Use of uninitialized value
by kevyt (Scribe) on Mar 14, 2012 at 02:38 UTC
    This worked.
    if ($filesize){ copy($$file, $$file . '_backup'); }