This is a quiz. Below are 6 examples of perl "bugs" that have been
reported to perl5-porters in the last 3 weeks and determined to be not bugs. One
reporter, (I believe) the only perlmonk among them, had already figured
out the difficulty and was providing a documentation patch to clarify
things. Of the others, four are somewhat documented.
Your mission, should you choose to accept it, is to find the
documentation (if any) that supports perl's actual behaviour.
Or at least figure out why perl is doing what it is doing.
Or at least have some fun and maybe learn something new.
use strict;
use warnings;
use vars '$x';
sub ok ($$)
{
my ($testnum, $check) = @_;
if ($check) {
print "ok $testnum\n";
} else {
print "not ok $testnum\n"
}
}
$x=0; { no strict 'refs'; my $x=42; my $y = 'x'; ok 1, ${$y} == 42; }
ok 2, eval 'no warnings; sub Foo::INIT { 42 } &Foo::INIT();';
$x="ad"; for ($x) { /a/gc; /\Gb?/gc; ok 3, /\Gc?/gc; }
ok 4, eval ' "(R)" =~ m(\(?r\)?)i ';
$x=1; { my $x=2; sub x {eval '$x'} } { my $x=3; ok 5, x; }
ok 6, 17.98 == 17.99 - .01;
Update: reordered the tests (before any replies)
Update: verbosify ok() sub
In reply to notabug quiz
by ysth
-
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.
|