The \ in /^\#/ is not nessessary (although it doesn't hurt since 
"\#" == "#"). Let me write some pseudo code and you tell me if it is
what you meant.

for each key in the hash count 
    go to the next key unless the key contains a digit character
    go to the next key if the contains p2 or P2
    go to the next key if the first character is #
  
On 02 Jun 2001 18:52:19 +1000, chris robinson wrote:
> 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!
> > 
> > 

-- 
Today is Pungenday, the 7th day of Confusion in the YOLD 3167
Frink!


Reply via email to