|Think about Loose Coupling|
Re^2: messing with @_by polettix (Vicar)
|on Jun 26, 2008 at 22:58 UTC||Need Help??|
I'm not particularly fond of using split in scalar context, in a general habit of avoiding anything that complains. Anyway, the behaviour seemed interesting.
After reading the warning, I did look at the docs:
In scalar context, returns the number of fields found and splits into the @_ array. Use of split in scalar context is deprecated, however, because it clobbers your subroutine arguments.Now, what's probably not particularly clear here is what clobbering stands for. The most natural interpretation seems (for me, of course!) to be "assigns something to your argument list, so it won't be the same any more", which is what seems to happen at the very first call to split. What I find surprising is that subsequent calls seem to imply a more general form of "clobbering", i.e. completely messing @_ contents. Given these two different "clobbering" flavours, I was wondering if it wasn't the time to promote the warning to an error.
I don't fully catch the consideration about "action-at-a-distance". If I catch my parameters at the very beginning:
I'd say that the warning doesn't apply, and I wouldn't see many problems in using @_ for other purposes, much like $_ is used for scalars. Apart, of course, that the behaviour isn't predictable here, so it has no use.
The bottom line is that my understanding of "clobbering" was quite poor here. So I'd like to understand if "clobber" expresses this "completely messing up @_ contents, which aren't reliable any more and should not be considered" or not. Anyway, the fourth example shows that @_ can't even be used any more, so there seems to be space for an error more than a warning. But this is the main reason why I'm a SOPW :)
perl -ple'$_=reverse' <<<ti.xittelop@oivalfIo ho capito... ma tu che hai detto?