Perl Monk, Perl Meditation | |
PerlMonks |
Re^2: DWIM Part Nineteen: Unary Operators in Void Contextby CheeseLord (Deacon) |
on Aug 21, 2001 at 18:43 UTC ( [id://106585]=note: print w/replies, xml ) | Need Help?? |
CheeseLord decides to risk exposing a possible misunderstanding of context issues... Actually, you're on the right track. The final line of the function is in void context because the function itself was called in void context. Tweaking your example a bit will show this:
Will print "funk". However, if we change the context of the function call...
We get "fUnK" printed out. $bar, incidentally, now contains 'funk'. So, you are correct, AFAICT. The solution would be to either switch the calls to lc and chop, or add an extra line returning what we want at the end. I was always in favor of explicit returns, anyway... (Of course, you could always not use my lc, but where would the fun be in that? ;-)) For those interested (and for those looking for holes in my reasoning), here's what the Void::lc looks like:
Update: Minor tweak to lc code. (Should do straight copy and paste next time...) His Royal Cheeziness
In Section
Meditations
|
|