Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: File remaing and removal to a subdirectory

by bwana147 (Pilgrim)
on Jul 11, 2001 at 17:30 UTC ( [id://95673]=note: print w/replies, xml ) Need Help??


in reply to Re: File remaing and removal to a subdirectory
in thread File renaming and removal to a subdirectory

albeit untested

Indeed ;-) A couple of things go wrong. @infiles is not initialised, but I guess this is left as an exercise to the OP. No, I really wanted to point out the use of exit, which is not what you want here, IIUC. exit terminates the program however deep you are in nested blocs. By using exit here, you stop the program once the first file has been renamed with a suffix. Instead of that, you want to proceed to the next file.

But next goes to the next iteration of the innermost loop. In our case, that would be the loop on suffices, not on files. So you'll need to use LABELS:
FILE: foreach my $filename (@infiles) { ... if ( -e $ofilename ) { SUFFIX: for (@suffix) { if ( ! -e "$ofilename.$_" ) { ... next FILE; } else { ... } } } else { ... } }

--bwana147

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://95673]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found