This is the code:
use 5.010;
use strict;
use warnings;
use Data::Dumper;
use Config;
my @list = ("housekeeper" =~ /keeper/,
"housekeeper" =~ /^keeper/,
"housekeeper" =~ /keeper$/,
"housekeeper\n" =~ /keeper$/);
say "list";
say scalar(@list);
print Dumper(@list);
foreach(@list) {
say;
}
my @other_list = (1 == 1, 1 == 0, 0 == 0, 1 != 0);
say "other_list";
say scalar(@other_list);
print Dumper(@other_list);
foreach(@other_list) {
say;
}
I was expecting 4 "boolean" values in the @list array. But apparently it only has 3 elements, all truthy ones. The @other_list has 4 elements as I was expecting. What am I missing here?
I've got the same results on windows (strawberry-perl-5.28.0.1-64bit-portable) and linux (5.018002)
Thanks!
-
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.
|