in reply to Rename filenames in perl using regex

Not difficult once you turn it into an algorithm. I suggest you try that first and read the hint if you get stuck.

use strict; use warnings; my @flist = qw/MY.switch.Org.1st.txt router.2nd.Org.MY.txt 3rdswitchmy +org.txt/; for my $file (@flist) { $file =~ /(router|switch)/i or next; my $rs = uc $1; $file =~ /(\d+)(st|nd|rd)/i or next; my $pos = uc "$1$2"; print "$pos.$rs.MY.ORG.TXT\n"; }

Replies are listed 'Best First'.
Re^2: Rename filenames in perl using regex
by Anonymous Monk on Sep 02, 2014 at 18:47 UTC
    you are the best.... Thank you very much.