BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
You get the following warning if you use split in a scalar context to count the number of whitespace delimited tokens in a string.
$_ = 'a b c d e'; print scalar( split );; Use of implicit split to @_ is deprecated at (eval 6) line 1, <STDIN> +line 1. 5 $_ = 'a b c d e'; print $n = split;; Use of implicit split to @_ is deprecated at (eval 9) line 1, <STDIN> +line 4. 5
I understand the warning, and that it is (mostly?) inappropriate in these cases.
Shouldn't (or couldn't) this warning only be produced in a void context? Or are there scalar context cases that I haven't thought of when it is appropriate?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: More intelligent warning?
by Corion (Patriarch) on Feb 05, 2010 at 14:19 UTC | |
by BrowserUk (Patriarch) on Feb 05, 2010 at 14:57 UTC | |
by Corion (Patriarch) on Feb 05, 2010 at 15:02 UTC | |
by LanX (Saint) on Feb 05, 2010 at 15:53 UTC | |
by BrowserUk (Patriarch) on Feb 05, 2010 at 16:39 UTC | |
by chromatic (Archbishop) on Feb 05, 2010 at 18:33 UTC | |
| |
by LanX (Saint) on Feb 06, 2010 at 01:26 UTC | |
by JavaFan (Canon) on Feb 05, 2010 at 16:06 UTC | |
by BrowserUk (Patriarch) on Feb 05, 2010 at 16:34 UTC | |
by shmem (Chancellor) on Feb 07, 2010 at 18:43 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2010 at 01:26 UTC |