Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: I need to install PERL MODULE first and then use it in the same SCRIPT. Is it possible

by tobyink (Abbot)
on Nov 29, 2012 at 08:32 UTC ( #1006196=note: print w/ replies, xml ) Need Help??


in reply to I need to install PERL MODULE first and then use it in the same SCRIPT. Is it possible

Try:

BEGIN { # This unless block just seems a little clearer than the # way you were doing it. # unless (eval { require Term::Menus }) { print "INSTALLING PERL Term::Menus MODULE\n\n"; system("/opt/hp/hadooptools/validation/smoke/cpan.sh Term::Menus +"); } } use Term::Menus;

Explanation: use happens at compile-time, before your check/install code runs. Wrapping it in a BEGIN block "lifts" that code to compile-time.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: I need to install PERL MODULE first and then use it in the same SCRIPT. Is it possible
Select or Download Code
Re^2: I need to install PERL MODULE first and then use it in the same SCRIPT. Is it possible
by rahulruns (Beadle) on Nov 29, 2012 at 09:06 UTC

    Thank you pointing in right direction a great help

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2015-07-06 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls