perl, how to make a system call and pass parameter

$exitval = system "scripts/myscript.pl";   #this works
$exitval = system "scripts/patch_fdcs.pl $MYDIR";  #this does not work

It has to be a system call and not backticks.  So how do I send parameter?
rgbcofAsked:
Who is Participating?
 
zicevaConnect With a Mentor Commented:
It should be:

system("command","arg1","arg2");

So, this should work:

$exitval = system("scripts/patch_fdcs.pl", "$MYDIR");
0
 
ozoCommented:
What did you try, and what were the results that lead to the conclusion that it does not work?
0
 
ozoConnect With a Mentor Commented:

$exitval = system "scripts/patch_fdcs.pl", $MYDIR;
would be preferable to
$exitval = system "scripts/patch_fdcs.pl $MYDIR";
if $MYDIR contains metacharacters that you don't want interpreted by the shell,
But they should otherwise be equivalent, and both can work.


0
 
parparovCommented:
What are $? and $! values after the system() failure?
0
 
rgbcofAuthor Commented:
Works great.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.