Update: Scratch that, reap the post, call me a fool. I should have invoked perl with the -l switch. The behavior is consistent. I dinn' catch the string "bug!" just in front of the shell prompt.
Update: changed title
Dear fellow monks,
playing with prototypes for a future perl talk at $work, I stumbled over the following (perl v5.14.3):
# file proto.pl
sub fn($);
fn("no bug.");
sub fn (\@) {
print while $_ = shift;
}
__END__
Prototype mismatch: sub main::fn ($) vs (\@) at proto.pl line 6.
That's fine and expected.
However, if the parameter list @_ isn't altered via shift, the fatal error is turned into a warning:
# file proto.pl
sub fn($);
fn("bug!");
sub fn (\@) {
print $_,$/ for @_;
}
__END__
Prototype mismatch: sub main::fn ($) vs (\@) at proto.pl line 6.
bug!
Would you consider that a bug, and if so, is it worth reporting?
-
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.
|