Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: Calculations before using lib;

by afoken (Monsignor)
on Aug 05, 2014 at 04:40 UTC ( #1096243=note: print w/replies, xml ) Need Help??

in reply to Re: Calculations before using lib;
in thread Calculations before using lib;

As perl needs to know the arguments for use lib before calling lib's import method, every expression used there is implicitly in a BEGIN block equivalent. So I often use a construct like this in my code:

#!/usr/bin/perl use strict; use warnings; use FindBin (); use lib do { (my $dir=$FindBin::Bin)=~s|/foo/|/bar/|; $dir };

This can also be used with taint mode to untaint the value of $FindBin::Bin:

#!/usr/bin/perl -T use strict; use warnings; use FindBin (); use lib do { $FindBin::Bin=~m|^(/.*)| or die "Can't find myself"; "$1/ +../lib" };


Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1096243]
[TCLion]: Good Morning Monks, I am parsing logs and some date time formats are inconsistent. I am trying to make output all same format. What is the best way to convert a month(word) to month(number)?
[Corion]: TCLion: I'm not aware of a better way than manually building the hash, as all strptime incarnations I know have nasty edge cases

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-03-23 14:40 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (287 votes). Check out past polls.