[PBP-pm] what's the correct way to do eval
Chris Dolan
chris at chrisdolan.net
Wed Dec 26 18:01:37 PST 2007
On Dec 25, 2007, at 11:03 PM, Randal L. Schwartz wrote:
>>>>>> "Chris" == Chris Dolan <chris at chrisdolan.net> writes:
>
> Chris> Huh? Isn't the following equivalent?
>
> Chris> my $has_proc_pid_file = eval "require Proc::PID::File;
> Chris> Proc::PID::File->import; 1;";
>
> It's the eval $string that P::C is complaining about. And there's
> not a good way around that.
>
How about this:
my $has_proc_pid_file;
eval { require Proc::PID::File; Proc::PID::File->import;
$has_proc_pid_file = 1; };
Or perhaps this is equivalent (untested):
my $has_proc_pid_file = eval { require Proc::PID::File;
Proc::PID::File->import; 1; };
Chris
More information about the PBP-pm
mailing list