I have the following code

}

foreach $word (sort keys %count) {
 next unless $word =~ /\d/;
 next if $word =~ /p2/i;
 next if $word =~ /^\#/
;  

have i got the final line right to ignore any lines that begin with a #??

thanks,
Chris
----- Original Message ----- 
From: "Chas Owens" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 02, 2001 6:35 PM
Subject: Re: regular expression


> in unix you can just use "grep -v '^ *#' filename > filename.new"
> 
> the equivalent perl code would look like this 
> 
> #!/usr/bin/perl
> while (<>) {                  # read lines from stdin or files named on
>                               # the command line
>     print unless (/^\s*#/);  # print $_ (which <> sets by default
>                              # unless $_ starts with zero or more
>                              # whitespace characters followed by a #
>                              # If you only want to eliminate lines
>                              # with # as the first character you can
>                              # use /^#/
> }
> 
> On 02 Jun 2001 18:14:56 +1000, chris robinson wrote:
> > I need to write a regular expression to eliminate any lines in a text =
> > file that start with a #.  how would I do this.
> > 
> > Many Thanks
> > 
> 
> -- 
> Today is Pungenday, the 7th day of Confusion in the YOLD 3167
> Hail Eris, Hack Linux!
> 
> 

Reply via email to