#! /usr/bin/perl use strict; my %file; # hash of filenames arrays keyed by suffix # first pass for (<*>) { push @{$file{$2}}, $_ if /(.*\.(.*))/; } # second pass for my $suffix (sort keys %file) { no strict 'refs'; next unless defined &{"handle_$suffix"}; &{"handle_$suffix"}($_) for sort @{$file{$suffix}} } # process the file with suffix '.cpp' sub handle_cpp { print "$_[0]\n"; }
-- stefp
In reply to Re: Best way to match items in an array
by stefp
in thread Best way to match items in an array
by ibanix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |