mndoci has asked for the wisdom of the Perl Monks concerning the following question:
This is not working as in the else statement the "do stuff" includes an open statement and , e.g., the script tries to open abc1.txt which of course does not exist. In other words if I find a file I want to open it, perform some other actions and move on and so on. I am trying a if (!(-f $file)) type syntax as I write this, but does anyone have a better idea. Thankschomp $_; # where $_ is the current line from the original list my $prefix = $_; my $txtfile = $prefix . ".txt"; if (-f $txtfile){ do stuff } else{ $txtfile1 = $prefix . "1.txt"; # the # is always 1 do stuff }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Files and -f
by Purdy (Hermit) on Dec 01, 2001 at 01:06 UTC | |
by mndoci (Scribe) on Dec 01, 2001 at 01:53 UTC |