develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Using smart matching to find whether an array contains a string

Thread Previous | Thread Next
From:
Ed Avis
Date:
January 26, 2011 06:22
Subject:
Re: Using smart matching to find whether an array contains a string
Message ID:
loom.20110126T152014-540@post.gmane.org
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.

-- 
Ed Avis <eda@waniasset.com>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About