SPUG: range operator

DeRykus, Charles E charles.e.derykus at boeing.com
Thu Mar 29 09:34:33 PDT 2007


 


> After running through Perltidy, this is the same as writing:

> while (<>) {
>     if ( /$start/ + 1 .. /$end/ - 1 ) {
>         print;
>      }
> }

> which of course is the same as writing:

> while (<>) {
>     if ( ((/$start/) + 1) .. ((/$end/) - 1) ) {
>         print;
>     }
> }



Great explanation...   and Deparse can expose parenthesized detail:


   $ perl -MO=Deparse,-p
   while( my $x = <>) {
      if($x=~m/$start/+1 .. $x=~m/$end/-1){
          print ;
      }
   }
   ^D

   while (defined((my $x = <ARGV>))) {
      if (((($x =~ /$start/) + 1) .. (($x =~ /$end/) - 1))) {
          print($_);
      }
   }
   - syntax OK

-- 
Charles DeRykus


More information about the spug-list mailing list