in reply to Messing with @_
I would think the answer to your question:
Anyone care to tell me why this code is dangerous?would be situational. I can think of a situation where it might be dangerous, but can't say whether it's dangerous to you.
An example of where it's dangerous is where the undef is intended in the defined interface to be meaningful. What if your args are:
@args = ( qw/fee fie foe fum/, func_that_returns_undef_for_error(), 1. +.3 );
Anyway, just brainstorming here. I think in the right situation you have a good idea.
Update: I was just thinking that if you're "messing" with the value so that you can present undef in output, perhaps you're looking to write a string_maybe_undef() function?
sub string_maybe_undef { $_ ? $_ : '' }
without actually messing with @_.print string_maybe_undef($_).": '".string_maybe_undef($_[$_])."'\n" fo +reach 0..$#_;
|
|---|