On Wed, Jan 26, 2011 at 02:22:02PM +0000, Ed Avis wrote: > Brad Baxter <bmb <at> mail.libs.uga.edu> writes: > > >>> perl -E '@a = ("1"); say "1 x" ~~ @a' > > >>This is a slightly unperlish distinction; usually in Perl it doesn't matter > >>whether a scalar holds the number 42 or the string '42' > > >Perhaps I misunderstand the example, but there is no time that I'm aware > >of when perl would store "1 x" in a scalar as a number. > > I was referring to this difference: > > % perl -E '@a = ("1"); say "1 x" ~~ @a' > > % perl -E '@a = (1); say "1 x" ~~ @a' > 1 > > So you have to be aware of the difference between 1 and '1'. > This is the only place in everyday Perl programming where the difference is > noticeable. False, unfortunally. $ perl -wE 'say 10 | 33' 43 $ perl -wE 'say "10" | "33"' 33 $ And it can even be more subtle: $ perl -E '$a = $b = "abc100"; 0 + $b; say $a; say $b; $a ++; $b ++; say $a; say $b' abc100 abc100 abc101 1 $ AbigailThread Previous | Thread Next