develooper Front page | perl.perl6.language | Postings from August 2006

Re: === and array-refs

Thread Previous | Thread Next
August 16, 2006 07:32
Re: === and array-refs
Message ID:
"Markus Laire" schreef:
> Dr.Ruud:
>> Markus Laire:

>>>     my $x = 'Just Another';
>>>     my $y := $x;
>>>     $y = 'Perl Hacker';
>>> After this, both $x and $y contain the string "Perl Hacker", since
>>> they are really just two different names for the same variable.
>>> </quote>
>> So "$x === Sy" stil[l] holds.
> Exactly, and because of that $a === $b does NOT hold in my example.
> ($a would be "Two", $b would be "One")

Yes, sorry for my over-compact reply. Where Darren wrote:

  The difference between === and eqv is that, if you have 2 symbols, $a
  and $b, and $a === $b returns true, then that result is guaranteed to
  be eternal if you don't assign to either symbol afterwards.

I think he meant something like "to either symbol (or alias)".
But read S03 for an exacter description.

I also wondered why a "simple" array (for example containing only value
type objects) whould not C<===> its copy.
But with .SKID that must be easy to handle.

Comparing strings in Perl5, using NFKD:

perl5 -MUnicode::Normalize -we '
  ($\, $,) = ("\n", "\t") ;
  $x = qq{Henry IV} ;
  $y = qq{Henry \x{2163}} ;
  print qq{<$x>}, qq{<$y>}, length $x, length $y, $x eq $y ? 1 : 0 ;
# $x = NFKD $x ;
  $y = NFKD $y ;
  print qq{<$x>}, qq{<$y>}, length $x, length $y, $x eq $y ? 1 : 0 ;
Wide character in print at -e line 5.
<Henry IV>      <Henry â.£>     8       7       0
<Henry IV>      <Henry IV>      8       8       1

How will the Str type do this?

Affijn, Ruud

"Gewoon is een tijger."

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About