We don't bite newbies here... much | |
PerlMonks |
Re: Tips for eleganceby Zaxo (Archbishop) |
on Jun 06, 2006 at 05:06 UTC ( [id://553745]=note: print w/replies, xml ) | Need Help?? |
Shelling out for file lists is pretty inelegant. Built-in glob can handle that,
You can dispense with the index $next by pushing elements onto the arrays. Your regex can be dressed up a little with quantifiers and built-in character classes. The if is necessary. Without it, you don't know that $1 and $2 are fresh. I added an end-anchoring $ to ensure .Z but not .Zoo files. I left off printing until they can happen in one discrete block.
Update: Woops, japhy++ spotted a feature I completely overlooked. That simplifies everything, and makes the regex completely unnecessary. With the above @ll is @name. New version, minus printing: That retains $path in the names, but those can be trimmed if you like using File::Basename. After Compline,
In Section
Seekers of Perl Wisdom
|
|