Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

RE: Odd file rename

by Anonymous Monk
on Jun 14, 2000 at 17:02 UTC ( [id://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.

    Nuance

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found