in reply to matching regex on an array element w/o looping the array
use warnings; use strict; use File::Find; my $dir = '/full/path'; my %fullpath; my @toget = qw/foo goo moo/; #my $pattern = join "|",@words; # bad mistake on my part my $pattern = join "|",@toget; find sub { $fullpath{$_} = $File::Find::name if -f $File::Find::name; +},$dir; for (keys %fullpath) { print $fullpath{$_}; if (/($pattern)/i) { print "\t$1\n" } else {print "\tNO MATCH\n";} }
--
Regards,
Helgi Briem
helgi AT decode DOT is
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: matching regex on an array element w/o looping the array
by gnu@perl (Pilgrim) on Oct 03, 2002 at 18:50 UTC | |
|
Re: Re: matching regex on an array element w/o looping the array
by gnu@perl (Pilgrim) on Oct 03, 2002 at 17:56 UTC | |
by helgi (Hermit) on Oct 04, 2002 at 13:35 UTC | |
by gnu@perl (Pilgrim) on Oct 04, 2002 at 19:33 UTC |