Richard Lee wrote:
say I have
my $var1 = 'abcdefg';
my @array = ( 'abcdefg_3432', 'defg_333', 'abcdefg_' , 'abcdefg_a' );
Let's say I want to go through the array to see if $var1 exists and also
to see if it followed by _ and then 4 digits (only first one should
quailfy , abcdefg_3432 )
I tried,
for (@array) {
next unless $_ =~ m#$var1_\d\d\d\d# ;
print "$_\n";
}
obviously this does not work.. so I tried
next unless $_ =~ m#{$var1}_\d\d\d\d#;
which also didn't work(? should it have worked?)
how do you normally match through regex when you have to compare more
than it's own variable?
perl -e "@array = ( 'abcdefg_3432', 'defg_333', 'abcdefg_','abcdefg_a');
$var1='abcdefg'; for(@array){print $_ unless !/$var1_\d{4}/g;}"
output is
abcdefg_3432
goksie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/