Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Passing parameters into a perl program.

by basicdez (Pilgrim)
on Mar 12, 2002 at 21:04 UTC ( #151228=perlquestion: print w/replies, xml ) Need Help??

basicdez has asked for the wisdom of the Perl Monks concerning the following question:

I totally know how to call a perl program from another perl program. I have currently been using back ticks, but is there a way to not only call another perl program but to pass it parameters as well?

peace

basicdez
  • Comment on Passing parameters into a perl program.

Replies are listed 'Best First'.
Re: Passing parameters into a perl program.
by dws (Chancellor) on Mar 12, 2002 at 21:15 UTC
    is there a way to not only call another perl program but to pass it parameters as well?

    TIMTOWTDI

    $output = `foo.pl $arg1 $arg2`; system("foo.pl $arg1 $arg2"); system("foo.pl", $arg1, $arg2);
    The difference in behavior between the last to examples is subtle, but worthy of study. It is well-described in perlfunc.

      Thanks
Re: Passing parameters into a perl program.
by derby (Abbot) on Mar 12, 2002 at 21:16 UTC
    basicdez,

    sure.

    • Pass 'em on the command line then read them out of @ARGV
    • skip backticks and system, use fork /exec, and pipe and send them from the parent to the child via STDIN
    • slightly more complicated: IPC

    -derby

Re: Passing parameters into a perl program.
by webadept (Pilgrim) on Mar 12, 2002 at 21:58 UTC
    Answer to your problem is above. If you are sending multiple parameters to an outside perl program, you may consider looking into building modules / classes or simply making an included function library. This way its easy to send and receive information and much more friendly on those that will see your code in the future.

    Of course there are plenty of valid reasons to do exactly what you are asking, so this is just a hint without cause :-)

    Glenn H.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://151228]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2022-01-28 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?