in reply to Re: shift doesn't DWIM
in thread shift doesn't DWIM

My memory may be incomplete or in need of refreshing, but I can't think of any subs that populate $_ as a default lvalue. Yes, there is the diamond operator in the special case of a while() loop, there is foreach(), the m// and s/// operators, and there are subs that utilize $_ as a default parameter. But there aren't any subs I can think of that populate $_ as though it were an lvalue.

Interesting question. I'm also having a hard time thinking of such functions...

map and grep assign to an implicitly localized $_ (as does foreach if no loop variable is given), but not their results.

The function readline clobbers $_ if it is in the test clause of a while loop:

% date|perl -le '$_="x";while(readline *STDIN){printf uc};print"<$_>"' TUE JUL 12 01:56:04 EDT 2005 <>

It wouldn't surprise me if there are more examples, but I can't think of any ATM.

the lowliest monk