Gossamer Forum
Home : General : Perl Programming :

Pseudohash

Quote Reply
Pseudohash
Anyone using pseudohashes?

If so, in which situtation is it advisable to use a pseudohash instead of a hash?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Pseudohash In reply to
No, I've never used them...they are far too complicating for my little brain :) ...it seems clearer to keep the arraryref/hashref seperate IMO.

Although I was just having a play about....

Code:
#!/usr/bin/perl

print "Content-type: text/plain\n\n";

my $phash = [ { HASH => 1, REF => 2 }, 'Element2', 'Element3', 'Element4' ];

print "$phash\n"; # It is an arrayref..ah but is it?
print "$phash->[1]\n"; # Hmm looks like an arrayref!
print "$phash->[0]\n"; # Ah but I'm a hashref :)
print "$phash->{HASH}\n"; # Erk I am a hashref...or am I?
print join ", ", grep !/HASH/, @$phash; # Non referenced elements

Last edited by:

Paul: May 12, 2002, 5:39 AM
Quote Reply
Re: [yogi] Pseudohash In reply to
I forgot to say, if you do use them you'll want to create then with the "fields" module...

Code:
use fields;

$phash = fields::phash( foo => 'bar', doo => 'dar' );

Last edited by:

Paul: May 12, 2002, 5:49 AM
Quote Reply
Re: [Paul] Pseudohash In reply to
Thanks for your answer.

That's what I also read in "Programming Perl", but they didn't have a real life example, so I was wondering I anyone might have one.....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Pseudohash In reply to
I've never found a use for them. They were generally considered a "failed experiment", and are probably going to be dropped from the language.

Have a look at:

http://dev.perl.org/rfc/241.html

an RFC for perl 6 which goes into some of the problems.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Pseudohash In reply to
Thanks for the information.

I'll forget about them....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Pseudohash In reply to
Hi yogi

An interesting node about this topic was posted earlier today over at the Monastry:

http://www.perlmonks.org/index.pl?node_id=166468

- wil
Quote Reply
Re: [Wil] Pseudohash In reply to
The Monastry? lol you take perlmonks way too seriously ;)
Quote Reply
Re: [Paul] Pseudohash In reply to
;-)

- wil