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 ) > > I tried, > > for (@array) { > next unless $_ =~ m#$var1_\d\d\d\d# ; > print "$_\n"; > } > > > obviously this does not work..
Most often you want \Q$var1\E inside your regex. See perldoc -f quotemeta. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/