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