in reply to matching regex on an array element w/o looping the array

For example, can I do this: if (@sourcefiles =~ /.*P.*\.0912\.ama\.gz/) { ..code.. };
if (grep /.*P.*\.0912\.ama\.gz/, @sourcefiles) { # ... code ... }

That isn't very efficient if you need the matches later though. It may well make more sense for you to save the list returned by grep.

my @matched = grep /.*P.*\.0912\.ama\.gz/, @sourcefiles; if (@matched) { # ... code ... }

By the way, this doesn't do it without looping the array. The grep() just hides the loop.

-sauoq
"My two cents aren't worth a dime.";