On Mon, Apr 16, 2001 at 11:37:14AM -0700, Prentice, Phillip R wrote:
> Hello,
> 
> I am fairly new to perl and am having problems matching a specific
> character.  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";
>   }
> }
> 
> This isn't giving the results I want, instead it will match the "_"
> character in the middle of the string as well as the end of the string.  Any
> ideas or suggestions on how this can be done?  Thanks in advance,

I have to say that people are making heavy weather out of this.  If you
want to match an underscore that the end of a string, that's what the RE
should say.  There's no need to match the whole string.


#!/usr/bin/perl -w

use strict;

my @array = qw(clk_n test_in_6_ clk_out);

for (@array)
{
    print if /_$/;
}


Verilog?

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to