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.
Example | 5.006 | 5.008 | 5.010 |
sin | dies | dies | dies |
time | 49274891.72 | 49274891.74 | 49274891.76 |
localtime | dies | dies | dies |
caller | dies | dies | dies |
eof | dies | dies | dies |
FOO | 1.4 | 1.4 | 1.4 |
LOCK_SH | dies | dies | 0.04 |
no_args | dies | dies | dies |
one_arg | dies | dies | dies |
normal | dies | dies | dies |
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;'
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|