in reply to 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!

I don't use Symbol::gensym anymore! Please, test and take a look in the module.

I still use GLOB, where it's cleanned with the object! Note that in Perl much things in your objects are GLOBAL, or have external access. (For example, when you use a IO::Handle, and any module that use it, like IO::File, you have a global GLOB object).

But any global thing in OO is wrong, I know. But for now is that, with GLOB! Looking for better ways...

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

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

Replies are listed 'Best First'.
Re: Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!
by diotalevi (Canon) on May 10, 2003 at 06:18 UTC

    How about posting the code here instead?

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

    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.

      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".

      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.