[pm-h] madness, genius or confusion?

Lanny Ripple lanny.ripple at gmail.com
Fri Mar 16 09:47:05 PDT 2012


Perl will happily skip unknown directories so

  use lib qw( /prod/path /stage/path /test/path );

would have been as effective.

Block eval is useful for catching exceptions.  String eval is useful when you must construct the code to be evaluated based on runtime input.  I've also abused BEGIN and @INC for dev/prod and hooking purposes (definitely falling on the madness end of the spectrum) but the original example presented isn't doing any of those things so I have to stick with "confusion".

For gory details see perldoc.perl.org on 'require', 'eval', 'lib'.

  -ljr


On Mar 16, 2012, at 10:14 AM, S Z wrote:

> I've seen something exactly like that. It helped when dev, staging, and test all had the lib in different locations... 
> 
> On Wed, Mar 14, 2012 at 5:04 PM, G. Wade Johnson <gwadej at anomaly.org> wrote:
> On Wed, 14 Mar 2012 10:44:13 -0500
> Bryan Rivera <brivera001 at gmail.com> wrote:
> 
> > Has anyone ever seen something like the code snippet below? I came
> > across this and figured I was just missing something. Why would you
> > want to 'use lib' inside an eval inside a BEGIN block? I think it's
> > all kinds of wrong.
> >
> > BEGIN {
> >     eval "{ use lib '/usr/prod/xxx/xxx/perl/lib/'; }";
> > }
> 
> The only reason I can think of is pretty unrealistic.
> 
> This construct would protect against the lib.pm module failing and
> still execute at compile time.
> 
> I would think that if you expected 'lib' to fail to load, there would
> not be much else you could do. So, I can't see a legitimate reason to
> do it.
> 
> But, someone obviously thought there was a reason...
> 
> G. Wade
> --
> The man who says he is willing to meet you halfway is usually a poor
> judge of distance.                             -- Laurence J. Peter
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/
> 
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/



More information about the Houston mailing list