Every time I get the warning "Use of implicit split to @_ is deprecated" I
have to go on a hunt to figure out what the hell I did wrong. perldiag
doesn't help.
Use of implicit split to @_ is deprecated
(D deprecated) It makes a lot of work for the compiler when you
clobber a subroutine's argument list, so it's better if you assign
the results of a split() explicitly to an array (or list).
Yeah, thanks, I wasn't splitting to @_!
What it really means, in 2009, is that you innocently used split in scalar
context and Perl did some wacky thing and its warning you that it did that
wacky thing. What it doesn't tell you is what you need to know: that split()
in scalar context does not DWIM.
Rather than fix perldiag, I just removed the LOOOOOOOOONG deprecated
"feature". How long? October 17, 1994. That's right, its a perl 4 feature
that was deprecated in 5.000. I think 15 years is long enough for everyone to
get the memo.
This makes $count = split / /, $thing; useful again and DWIM.
The diff to disable the feature is surprisingly short:
--- a/pp.c
+++ b/pp.c
@@ -4738,8 +4738,6 @@ PP(pp_split)
ary = GvAVn(pm->op_pmreplrootu.op_pmtargetgv);
}
#endif
- else if (gimme != G_ARRAY)
- ary = GvAVn(PL_defgv);
else
ary = NULL;
if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
I'm willing to guess there's lots of code inside split() which can now be
removed. Like that following line checking to see if ary exists outside list
context, which now cannot happen. But the code for split() is terrifying so
I'm going to do the minimal work.
A warning about use of split in void context should probably also be added.
That now does nothing but regex side effects and that's just a silly use of
split(). Again, I don't have the necessary core hacking bits to do that.
--
Insulting our readers is part of our business model.
http://somethingpositive.net/sp07122005.shtml
Thread Next