Re: Pseudo-hashes are deprecated
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Tue, 29 Jan 2008 08:33:21 -0500
On Jan 29, 2008 7:45 AM, Harry Bennett <harry@xxxxxxxxxxxxxxx> wrote:
I am using this line:snip
foreach my $pair (keys %{$config{server}}) {
.....
}
but get the warning:
Pseudo-hashes are deprecated at ......
I am using the example from 'Programming Perl (third edition)' Section 9.4.3
I guess my ultimate question would be, what have they been deprecated to?
And an example would be GREATLY appreciated.
The error is being printed at that line, but its cause is earlier in
your code. The following code has no error
#!/usr/bin/perl
use strict;
use warnings;
my %config = (
server => { one => 1, two => 2, three => 3 }
);
foreach my $pair (keys %{$config{server}}) {
print "$pair\n";
}
The error is really the use of pseudo-hashes. They have not been
replaced with anything because they turned out to be a bad idea. The
goal was to have the speed of an array, but the easy of use of a hash.
The implementation wound up doing neither and cluttering up the
source*. The other feature of pseudo-hashes, the compile time
checking of the keys, has been preserved in the fields pragma**.
* from http://use.perl.org/article.pl?sid=01/07/16/127257
The extra code to support pseudo-hashes slowed down all arrays
and hashes by 10 to 15%.
** see perldoc fields or http://perldoc.perl.org/fields.html
.
- References:
- Pseudo-hashes are deprecated
- From: Harry Bennett
- Pseudo-hashes are deprecated
- Prev by Date: Re: Pseudo-hashes are deprecated
- Next by Date: Re: Clear a hash
- Previous by thread: Re: Pseudo-hashes are deprecated
- Next by thread: Re: Pseudo-hashes are deprecated
- Index(es):
Relevant Pages
|