Phillip -

> I want to create a regular expression which will match $array{1} and not the
> others in the array.  This is what I have so far.
> 
>  foreach (@array) {
>   if(m/$\w+\_/) {
>    print "Matched, $_\n";
>   }
> }

To match at the end of the string, you should anchor with '$' at the end
of your pattern:

    if(m/\w+\_$/)

'^' will do the same for anchoring at the start of the string, when placed
at the start of the pattern.

Both Programming Perl and Learning Perl have excellent chapters on basic
regexes.



Reply via email to