Regular Expression and Substituting
Regular Expression and Substituting
- Each argument will be $_ for each file passed by @ARGV
- Notice the “i”, outside the slashes which says ignore case
- Transpose uppercase to lowercase characters of $_
- Original name saves to $currentname
- File is renamed to a filename which a DOS system can handle
foreach ( @ARGV )
{
if ( /GMIF1.[0-9]{5}/i )
{
$currentname=$_;
tr/[A-Z]/[a-z]/;
s/(gmi)f1.([0-9]{5})/\1\2.txt/;
rename ($currentname, $_);
}
}