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

Re: [perl #20616] Tie::IxHash doc error.

Thread Previous
From:
Rafael Garcia-Suarez
Date:
January 30, 2003 14:11
Subject:
Re: [perl #20616] Tie::IxHash doc error.
Message ID:
20030130231716.39268d11.rgarciasuarez@free.fr
Beckett Richard-qswi266 (via RT) wrote:
> Perldoc returns:
> 
>   How can I make my hash remember the order I put elements into it?
> 
>             Use the Tie::IxHash from CPAN.
> 
>                 use Tie::IxHash;
>                 tie(%myhash, Tie::IxHash);
>                 for ($i=0; $i<20; $i++) {
>                     $myhash{$i} = 2*$i;
>                 }
>                 @keys = keys %myhash;
>                 # @keys = (0,1,2,3,...)
> 
> Using Tie like this will cause an error with use strict. The line:
> tie(%myhash, Tie::IxHash);
> should be:
> tie(%myhash, 'Tie::IxHash');

Thanks. The code is correct by itself (since it doesn't include
"use strict"), but giving examples of code that don't refuse to
compile under strictures is obviously better. I've now corrected
this. (change #18605)

Thread Previous


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