Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: renaming files...

by plaid (Chaplain)
on Aug 08, 2000 at 22:06 UTC ( #26841=note: print w/replies, xml ) Need Help??


in reply to renaming files...

On the line
if ($TEMP1 =~ /(A-[0-9]+-[0-9]+)/) {
You want to take the output of the pattern match. $TEMP1 isn't being altered at all, it's just being matched against. The result of the pattern match is left in $1. Try this:
$DIR="."; opendir CONCEPT, $DIR || die "no such dir"; while ($TEMP = readdir(CONCEPT)) { if ($TEMP =~ /(A-[0-9]+-[0-9]+)/) { if (rename $TEMP, $1) { print $1; } } }
The code was editted as little as possible. Any stricting, -w'ing, and error checking is left as an excercise to the reader.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-06-07 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (42 votes). Check out past polls.

    Notices?