On Jan 31, 2008 10:06 AM, RICHARD FERNANDEZ <[EMAIL PROTECTED]> wrote:
> gzip "$company.$ext.$date" => "$company.$ext.$date.gz", > BinModeIn => 1 or do { > warn "Failed to gzip file: $company.$ext.$date: > $GzipError\n"; > next DOTDONE; > }; > </snip> > > The file "$company.$ext.$date" is created in the immediately preceding > step and definitely contains data, but the resulting compressed file is > empty, and the warn statement is not executed. Since your code is using string expressions to generate filenames on the fly, instead of storing the filepaths in variables, are you sure you're getting the strings that you think you're getting? How do you know the file "definitely contains data"? Let's take care of both questions at once: my $old_name = "$company.$ext.$date"; my $new_name = "$old_name.gz"; warn "File '$old_name' is empty" if -z $old_name; warn "File '$old_name' isn't really a file" unless -f _; unlink $new_name; # whether it's there or not gzip $old_name => $new_name, BinModeIn => 1 or do { warn "Failed to gzip file: '$old_name': $GzipError"; next DOTDONE; }; warn "File '$new_name' not created as expected" unless -f $new_name and -s _; > I've extracted and wrapped this code to create a little test program > which works fine, that is, the resulting compressed file contains the > data I expect. That would imply that the bug is in the other part of your code. Are you using both 'strict' and 'warnings'? Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/