PDA

View Full Version : perl 5.8 Blessing a reference to another ref


baggs
06-04-03, 10:26
Hi everyone,

We've just upgraged to perl 5.8. I've read on perl.com that in 5.8 'blessing a refence into another ref ' "led to some weird bugs and have been disabled, as they touched some rarely tested codepaths."

I fail to understand how this can be so. This means that any object that receives a reference, whether to a hash, etc cannot be blessed to a reference to that object. This breaks many objects I've written that have worked perfectly for years.

Heres what I mean....

Constructor

package HtmlSelect;

my $self = bless {
_Name => $arg{'Name'},
_List => $arg{'List'},
}

where $arg{'List'} is a reference to a hash.

In the object, when I try to foreach through the hash, its empty
As it is a reference, I need to dereference it with %
foreach my $item (keys %{$self->{_List}}) {
}

However if I write... (without the dereference)

foreach my $item (keys $self->{_List}) {
}

...it works.

"weird bugs" they are not kidding!

So my question is How do I work around this? That is receiving a ref to a hash to bless into an object referecne.

Any help would be greatly appreciated!

Thanks

Clinton

baggs
06-04-03, 11:35
Please disregard my last post. Sometimes I don't even know what Im talking about. lol

Thanks

baggs
06-05-03, 10:33
Disregard my last reply. My first post stands. In fact, you cannot bless a reference to a hash to another reference.

Anybody, any ideas?

Thanks