in reply to renaming files...
On the line
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:if ($TEMP1 =~ /(A-[0-9]+-[0-9]+)/) {
The code was editted as little as possible. Any stricting, -w'ing, and error checking is left as an excercise to the reader.$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; } } }
|
---|
In Section
Seekers of Perl Wisdom