Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying whatIs() to allow for scalar or array objects #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jackdeguest
Copy link

When using a scalar object, i.e. a blessed scalar reference, IO::Uncompress::Gunzip::gunzip and I suspect the other member of the IO::Compress family as well, rejects it with the error illegal input parameter.

It would be nice that it recognises those as scalar reference.

For example, consider the following code:

#!/usr/local/bin/perl
use v5.10;
use IO::Compress::Gzip;
use IO::Uncompress::Gunzip;
my $hello = 'Hello world';
my $compressed;
IO::Compress::Gzip::gzip( \$hello => \$compressed );
my $s = MyModule->new( $compressed );
my $hello;
eval
{
    IO::Uncompress::Gunzip::gunzip( $s => \$hello );
};
say $hello eq 'Hello world' ? 'ok' : 'not ok';
say $@ if( $@ );

package MyModule;
use strict;
use warnings;

sub new
{
    my $that = shift( @_ );
    my $str  = shift( @_ );
    return( bless( \$str => ( ref( $that ) || $that ) ) );
}

__END__

Before change, this would yield:

not ok
IO::Uncompress::Gunzip::gunzip: illegal input parameter

And after change: ok

@pmqs pmqs self-assigned this Apr 11, 2022
@pmqs pmqs added the enhancement New feature or request label Apr 11, 2022
@pmqs
Copy link
Owner

pmqs commented Apr 11, 2022

I avoided allowing any blessed references when I wrote this code because you have no idea what is lurking behind the reference.

Need to think about this proposal, plus it will need documented & the unit tests updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants