Help for this page

Select Code to Download


  1. or download this
      $str = '( (1 == 1) and (2 < 1) ) or (2 > 0)';
      while ($str =~ s/(\([^()]+\))/$1/ee) {
    ...
           last;
        }
      }
    
  2. or download this
      $str = '( (1 == 1) and (2 < 1) ) or (2 > 0)';
      while ($str =~ s/(\([^()]+\))/qq($1 || 0)/ee) {
           print eval($1) ? 'ok' : 'error';
           print ": $1\n";
      }
    
  3. or download this
    ok: (1 == 1)
    error: (2 < 1)
    error: ( 1 and 0 )
    ok: (2 > 0)
    
  4. or download this
      $str = '( (1 == 1) or (2 < 1) ) and (2 > 0)';