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!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.