Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my script report 'uninitialized value in eval "string"?

I am getting this warning:

Use of uninitialized value in eval \"string\" at myscript.pl line 57.

When I run this code:

eval;
{
        `$client -f $confFile -i $inputFile -o $outputFile`;
};

if( $@ )
{
        # error handling here ...
}

What is causing the error?

How can I fix the underlying cause? (Or otherwise suppress the warning?)

like image 689
mseery Avatar asked Jun 30 '26 23:06

mseery


1 Answers

The eval here would do absolutely nothing anyway. Backticks never throw errors. It's not $@ but $? that you want to check.

Also, if you're throwing away the result, it may be a cleaner idea to use system. e.g.

system($client, '-f', $confFile, '-i', $inputFile, '-o', $outputFile) and do {
    #error handling here...
};
like image 121
Leon Timmermans Avatar answered Jul 03 '26 13:07

Leon Timmermans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!