http://qs1969.pair.com?node_id=313616


in reply to Re: Re: How to get the number of fields found by split without a warning?
in thread How to get the number of fields found by split without a warning?

As davido points out, my question is : how to get rid of the warning.

And in as few keystrokes as possible, without a significant time overhead.

Finally, I decided to try the obvious solution : turn off warnings locally.

sub split_simple_quiet { no warnings; my $n = scalar split ',', $str; #print "$n\n"; }
This does the job and costs almost nothing in time, as the expanded benchmark shows:
Use of implicit split to @_ is deprecated at H:\dev\perl\perlmonks\ben +ch.pl line 23. Benchmark: timing 10000 iterations of split_anonymous, split_simple, s +plit_simple_quiet... split_anonymous: 24 wallclock secs (15.55 usr + 0.00 sys = 15.55 CPU) + @ 643.00/s (n=10000) split_simple: 20 wallclock secs (12.23 usr + 0.00 sys = 12.23 CPU) @ +817.80/s (n=10000) split_simple_quiet: 18 wallclock secs (12.15 usr + 0.01 sys = 12.16 C +PU) @ 822.57/s (n=10000) Rate split_anonymous split_simple split_si +mple_quiet split_anonymous 643/s -- -21% + -22% split_simple 818/s 27% -- + -1% split_simple_quiet 823/s 28% 1% + --
Rudif