ricardo_sdl has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: I was expecting 4 elements in the array, but it only has 3
by Paladin (Vicar) on Nov 28, 2018 at 17:08 UTC | |
by haukex (Archbishop) on Nov 28, 2018 at 17:13 UTC | |
Re: I was expecting 4 elements in the array, but it only has 3
by j41r (Beadle) on Nov 30, 2018 at 00:18 UTC | |
by AnomalousMonk (Archbishop) on Nov 30, 2018 at 03:43 UTC | |
by j41r (Beadle) on Nov 30, 2018 at 10:50 UTC |
Back to
Seekers of Perl Wisdom