in reply to Benchmark diamond operator
Hi, if I understand you correctly, the issue is that the diamond operator uses shift to iterate through @ARGV, so the second sub will find it empty.
$ perl -Mstrict -Mwarnings -E 'say "starting: " . scalar @ARGV; while( +<>){chomp; say "$_\nremaining: " . scalar @ARGV}' foo bar baz
starting: 3 foo remaining: 2 bar remaining: 1 baz remaining: 0
Hope this helps!
Update: added demo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Benchmark diamond operator
by thanos1983 (Parson) on May 09, 2017 at 14:47 UTC |