in reply to gunzip exception

Maybe check if $gz is an empty string and don't try to call gunzip() in that case?

I also can't reproduce your problem. eval catches the error message correctly for me with your code (amended below to show that):

use 5.012; use warnings; use Gzip::Faster; my $gz=""; my $data; eval {$data=gunzip($gz)}; if($@) { say qq(error: $@) }; say "Done"

This gives me the output:

Attempt to uncompress empty string at ... Done

Most likely the code you post is not the code you run.

Replies are listed 'Best First'.
Re^2: gunzip exception
by luxs (Beadle) on Feb 08, 2021 at 10:38 UTC
    my $gz = 'f'; my $data; eval { $data = gunzip( $gz );}; if ($@) { say "Something wrong"; exit; }; say "done";
    Produce Attempt to uncompress empty string at ./aa.pl line 11. done which mean - generate fatal error but not recognize it YES, i will check that the file is not empty before using gzip - it will be easier for now