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 04:02
Subject:
Re: Using smart matching to find whether an array contains a string
Message ID:
loom.20110126T125145-901@post.gmane.org
Eric Brine <ikegami <at> adaelis.com> writes:

>>but I suggest an explicit entry in the 'Smart matching in detail' section
>>to document the case when $a is an array and $b is a string, which is
>>currently missing.
>
>It's not missing at all.
> 
>Any   Any      string equality   $a eq $b

Yes I realize that it would be redundant to add an explicit entry for
'Array  String'.  But the documentation needs to be clear more than it needs
to be minimal.  In this particular case, because the behaviour has changed
since 5.10.0, I think an explicit note would be helpful.

    Array    String   string equality    [*]
      [*] these cases have changed, see perl5120delta

Further, it's not clear how the '$a eq $b' in the 'Any  Any' line applies
when the left hand side is not a scalar but an array; not $a but @a.

But I don't see that 'string equality' is the semantics?

    % perl -E '@a = (1, 2, 3); $s = "@a"; say(@a ~~ $s)'

-- 
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