http://www.perlmonks.org?node_id=965314


in reply to Re^2: run perl script with cmd line in shell
in thread run perl script with cmd line in shell

3)Embed the command line arguments into the top of your script.pl, perhaps as you are sending it across the wire to perl. This would require some pre-processing of the script and some assumptions of where you can embed the code - if I were to do it this way, I would probably have a token of some sort in the script that I would replace with my parameters --> The cmd line argumetns are also dynamic in nature..but i dont understand this entire statment correctely. can you give an example ?

In your script you could have something like:

# Earlier stuff in the script... # Fill in the arguments if running remotely @ARGV ||= qw(%%REPLACEDTOKEN%%); # ... and back it out if @ARGV should really be empty @ARGV = () if $ARGV[0] eq "\%\%REPLACEDTOKEN\%\%"; # Rest of your script
At this point, you would use something locally to replace '%%REPLACEDTOKEN%%' with your parameters, and pipe that to a perl call on the remote machine.

sed -e .... < script.pl | ssh user@remote perl

I still have concerns that this is the most robust solution to your problem.

Do your scripts use any temporary files? If so, I would seriously reconsider your answer to number 2. If you can write temp files, you can also write a temporary perl script.

--MidLifeXis