Richard Lee schreef: > 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 )
for my $item ( @array ) { next unless $item =~ m/^\Q$var1\E_[0-9]{4}$/; print $item, "\n"; } or in more steps: for my $item ( @array ) { next if substr( $item, 0, length $var1 ) ne $var1; next if substr( $item, length $var1 ) !~ m/^_[0-9]{4}$/; print $item, "\n"; } (untested) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/