in reply to Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!
in thread Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!

Eh - I just created Lexical::Typeglob. For the moment it exists on my web site at http://www.greentechnologist.org/downloads/perl/ and it'll go on CPAN soon-ish.

Added: You know what? I'm a moron - Symbol already does this and the whole reaping issue is moot.

  • Comment on Re: Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!

Replies are listed 'Best First'.
Re: Re: Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!
by gmpassos (Priest) on May 10, 2003 at 09:15 UTC
    Cool! ;-P

    As I said in CB. I have found another way to save the different data types without GLOB! ;-P

    Now I'm using just a anonymous hash blessed. I have created a package for a Saver object of the data, where you have $saver->hash and $saver->set_hash...

    How you made the Lexical::Typeglob? It works for multiple objects? I say that because I was trying to use local(*FOO), but doesn't work when you have more than 1 object!

    Update: I have extended the multi type for CODE and GLOB, soo you can make:

    my $multi = Object::MultiType->new( code => sub{ print "CODE!\n" } , glob => \*STDOUT , ) ; &$multi(args) print $multi "Hello!" ;

    Graciliano M. P.
    "The creativity is the expression of the liberty".

Re: Re: Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!
by diotalevi (Canon) on May 19, 2003 at 17:20 UTC

    I just updated Lexical::Typeglob to 0.02. The *{lexglob()}{NAME} expression used to return undef, now it returns "". Similarly, *{lexglob()}{PACKAGE} used to cause perl to dereference a null pointer, now it just returns "". This probably isn't a serious issue since I don't think fetching PACKAGE is high on many lists for features.