Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

RE: Odd file rename

by Anonymous Monk
on Jun 14, 2000 at 17:02 UTC ( #18083=note: print w/replies, xml ) Need Help??

in reply to Odd file rename

The only problem with using $oldname $newname is that I will be doing this automatically for a large number of files, and the names for each will be different - though the naming convention will be the same for all of them.

F1234 -> B1234
F2345 -> B2345
F3456 -> B3456

I guess that didn't quite come through in my initial explanation. =)

Replies are listed 'Best First'.
RE: RE: Odd file rename
by t0mas (Priest) on Jun 14, 2000 at 17:19 UTC
    I really can't see your problem with that. Try:
    my @fileList=("F1234","F2345","F3456"); foreach $oldname (@fileList) { $newname=$oldname; $newname=~ s/^./B/i; rename($oldname,$newname) };
    (credits for regexp to lhoward)

    /brother t0mas
RE: RE: Odd file rename
by nuance (Hermit) on Jun 14, 2000 at 17:09 UTC

    the first part of the post you are referring to tells you how to set $oldname and $newname to something sensible before you do the link/unlink operation. Granted there is a large comment in the middle, but that merely discusses an alternative method for setting $oldname and $newname.

    Please read it again, you will see that you did come over correctly and they have indeed answered your question.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2021-05-13 05:32 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (134 votes). Check out past polls.