in reply to Re: How can I avoid code repetition here
in thread How can I avoid code repetition here

Your code will not work if $_ is lexical.
You can't make $_ a lexical:

$ perl -lwe "my $_='abc'; chop; print" Can't use global $_ in "my" at -e line 1, near "my $_" Execution of -e aborted due to compilation errors.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: How can I avoid code repetition here
by JavaFan (Canon) on Oct 08, 2009 at 09:48 UTC
    You have been able to do that for the past 22 months:
    $ perl -wle 'my $_ = "abc"; chop; print' ab $
      Which Perl version was this introduce in? I still used 5.8.8, so it was illegal there. I see that it works in 5.10

      -- 
      Ronald Fischer <ynnor@mm.st>
        5.10. Which was released about 22 months ago. You shouldn't be claiming things are not allowed if all you do is check it against an old version of Perl.