in reply to Re: if/while/else problem
in thread if/while/else problem

Thanks for the suggestion, but it still prints my 'else' even when the 'if' should have been processed instead.

Replies are listed 'Best First'.
Re^2: if/while/else problem
by eff_i_g (Curate) on Mar 25, 2009 at 19:13 UTC
    Then there must be confusion with file. How about something like this?
    use warnings; use strict; my $in = 'file' my $out = 'file2'; open my $OUT, '>', $out or die $!; if (-s $in) { open my $IN, '<', $in or die $!; while (<$IN>) { my $line = $_; chomp $line; print $OUT "$line\n"; print $OUT "you need to do this\n"; print $OUT " \n"; } } else { print $OUT "There is nothing to do\n"; }