Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: renaming files...

by plaid (Chaplain)
on Aug 08, 2000 at 22:06 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://26841]
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 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found