in reply to Writing compact conditional regex's
If I understand your first two lines correctly, you're trying to isolate just the filename, without '.avi'. You can use the /b switch, along with /s, to get a bare listing, and then parse out the filename on the fly.
File::Find would also be an excellent choice, but I'm just commenting on the code you have.
The two patterns are almost identical, so just anchor the second one, use a character class ([xe]), and you should be good.
And lastly, you can put most of that into the for loop, and use the regexes on $_ instead of creating temporary variables.
--marmotfor( map{ s/\\*([^\\]+)\.avi\n/$1/; $_ } `cmd /c dir /s /b *.avi` ) { $inventory{$1} = $2 if /^(.*?)s\d{1,2}[xe]\d{1,2})/i); } # BROKEN OUT -- follow the numbers for( map{ s/\\*([^\\]+)\.avi\n/$1/; # 2: isolate filename between last # backslash (if any) and newli +ne $_ } # 3: pass on $_, not result of s// +/, which is the # number of replacements made `cmd /c dir /s /b *.avi` # 1: get avi files, including sub- +dirs. # dir is a shell (cmd) command +, so # you might need to call it th +is way. ) { $inventory{$1} = $2 if /^(.*?)s\d{1,2}[xe]\d{1,2})/i); }
In Section
Seekers of Perl Wisdom