Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    3

    Unanswered: perl 5.8 Blessing a reference to another ref

    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

  2. #2
    Join Date
    Jun 2003
    Posts
    3
    Please disregard my last post. Sometimes I don't even know what Im talking about. lol

    Thanks

  3. #3
    Join Date
    Jun 2003
    Posts
    3

    Me again

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •