Syntactic Confectionery Delight | |
PerlMonks |
Re: One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.by choroba (Cardinal) |
on Oct 16, 2020 at 16:55 UTC ( [id://11122914]=note: print w/replies, xml ) | Need Help?? |
As documented in perlop, the substitution > Searches a string for a pattern, and if found, replaces that pattern with the replacement text and returns the number of substitutions made. Your s/// replaced once, so it returned 1. Run the substitution before printing the result.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|