[PBP-pm] what's the correct way to do eval

Chris Dolan chris at chrisdolan.net
Tue Dec 25 21:00:23 PST 2007

On Dec 24, 2007, at 9:59 PM, Randal L. Schwartz wrote:

>>>>>> "Fayland" == Fayland Lam <fayland at gmail.com> writes:
> Fayland> have to replace this:
> Fayland> my $has_proc_pid_file = eval "use Proc::PID::File; 1;";
> Fayland> it complaints Expression form of "eval" at line 7, column  
> 25. See page
> Fayland> 161 of PBP.
> There *is* no replacement for that, which is why PBP is a guide,  
> not a gospel.
> What you did is perfectly fine for that task.

Huh?  Isn't the following equivalent?

   my $has_proc_pid_file = eval "require Proc::PID::File;  
Proc::PID::File->import; 1;";

I'm not saying it's definitely better, but I thought it was a valid  
replacement.  In fact, I was sure of it until I noticed it was Randal  
saying otherwise.  :-)


More information about the PBP-pm mailing list