in reply to How to make an IO::Uncompress::Bunzip2 look like a GLOB

if(UNIVERSAL::isa($file,'GLOB')){...}

if(UNIVERSAL::can($file,'print')){...}

  • Comment on Re: How to make an IO::Uncompress::Bunzip2 look like a GLOB

Replies are listed 'Best First'.
Re^2: How to make an IO::Uncompress::Bunzip2 look like a GLOB
by Pascal666 (Scribe) on Aug 18, 2009 at 03:08 UTC
    I believe your reply contains suggestions for modifying the "if" inside the Perl Module. My question was actually how to modify the object I am passing the module such that it would pass the existing "if" inside the module, so that I do not have to modify the third party module.
      The 3rd party module has a giant bug, it needs to be fixed. But
      { local @GLOB::ISA = ref $obj; bless $obj, 'GLOB'; broken_module($obj); bless $obj, @GLOB::ISA; }

        Thank you. That does indeed get me past the initial "if". Unfortunately the restore part of your code does not appear to work. With that code I get:

        Can't locate object method "READ" via package "1"

        If I change your last line to

        bless $obj, 'IO::Uncompress::Bunzip2';

        then it works correctly. Thank you for your help.

Re^2: How to make an IO::Uncompress::Bunzip2 look like a GLOB
by Pascal666 (Scribe) on Sep 04, 2009 at 03:55 UTC

    The statement:

    if(UNIVERSAL::can($file,'print')){...}

    does not appear to work. I have tried passing it both a string and a GLOB and it never seems to evaluate to true.

      Ouch, then  *{$file}{IO}, see *glob{FILEHANDLE}

      Probably the best idea is to simply try to use $file without checking what it is

      $file->print('asdf');