On Jan 2, Booher Timothy B 1stLt AFRL/MNAC said:

>Why is ((/^\*+/) or (/^\s*$/)) improper? 
>
>It breaks down to:
>( (/^\*+/) or (/^\s*$/) )

Yes... but neither of those are testing $line, they're testing $_.

>How is this different than: "next if $line =~ /^\*+/ or $line =~ /^\s*$/;"
>except that it is less ambiguous?

It's wrong.  Regexes are not distributative over the =~ operator, just
like you can't say

  if ($x == (1 or 2 or 3 or 4)) { ... }

If you use that, the (1 or 2 or 3 or 4) is evaluated (it returns the value
1) and so the test becomes

  if ($x == 1) { ... }

You have to use the "long" way.

  next if $line =~ /this/ or $line =~ /that/;

If you want to write less, use $_ to begin with!

  while (<FH>) {
    next if /this/ or /that/;
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to