#!/usr/bin/perl -w
use strict;
eval ' my $x= hello() or die $x->error(); 1 '
or warn "$@\n";
eval ' my $y= hello() || die $y->error(); 1 '
or warn "$@\n";
__END__
Global symbol "$x" requires explicit package name at (eval 1) line 1.
Global symbol "$y" requires explicit package name at (eval 2) line 1.
The use of or is more correct for code like this since, when hello() fails, you don't want $x set to the return value of die. Of course, die doesn't return so this isn't a good example.
But or doesn't cause what comes after it to be a separate statement so the my still hasn't created the variable yet.
-
tye
(but my friends call me "Tye") |