http://www.perlmonks.org?node_id=736045


in reply to On Parsing Perl

I decided to run this test script under various versions of Perl.
@examples = split /\n/, <<'EXAMPLES'; sin / ... time / ... localtime / ... caller / ... eof / ... use constant FOO => 35; FOO / ... use Fcntl qw(LOCK_SH); LOCK_SH / ... sub no_args (); sub no_args{1}; no_args / ... sub one_arg ($); sub one_arg{1}; one_arg / ... sub normal (@); sub normal{1}; normal / ... EXAMPLES for (@examples) { s=\.\.\.=25 ; # / ; die "this dies!";=; local($a) = eval; $a = $@ if $@; print "$_\n\t$a\n"; }
I don't know what the results would be for earlier versions, but from Perl 5.6 onwards it's pretty consistent.
Example5.0065.0085.010
sindiesdiesdies
time49274891.7249274891.7449274891.76
localtimediesdiesdies
callerdiesdiesdies
eofdiesdiesdies
FOO1.41.41.4
LOCK_SHdiesdies0.04
no_argsdiesdiesdies
one_argdiesdiesdies
normaldiesdiesdies
Most of the "dies" instances also produced this message: Warning: Use of "XXX" without parentheses is ambiguous at (eval N) line 1. However, the LOCK_SH example never generated errors, while the last three generated "Prototype mismatch" messages. I must also note that almost all of the examples generated warnings, despite using neither the '-w' option or 'use strict;'