On Mon, Apr 16, 2001 at 11:37:14AM -0700, Prentice, Phillip R wrote:
>
> I want to be able to match the "_" character at the end of a string.
> For example, asume I have an array of strings with the following data:
>
> $array{0} = "clk_n"
> $array{1} = "test_in_6_"
> $array{2} = "clk_out"
>
> 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";
> }
> }
You seem to have your '$' misplaced in your pattern. '$' in a regex
anchors a match at the end of a string. Also, since '_' is not special
in a regex, it doesn't need backslashing. Based on your example above,
C<m/\w+_$/> may be what you're looking for. See the perlre manpage.
dha
--
David H. Adler - <[EMAIL PROTECTED]> - http://www.panix.com/~dha/
package Warnings::DHA;
sub import {require Carp; $SIG{__WARN__}=sub{local $Carp::CarpLevel=1;
Carp::carp("DIE YOU GRAVY SUCKING PIG!")}}