By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

inovking a perl script in a script

P: 36
Hi,

i have a perl script 123.pl and in that script i am trying to invoke 234.pl which takes one command line argument .is there any way that we can achive the same?
Aug 8 '08 #1
Share this Question
Share on Google+
2 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
What have you tried thus far to do this? Have you looked at the system() function?

Regards,

Jeff
Aug 8 '08 #2

P: 14
As suggested by Jeff, you can use 'system' function to call another Perl program from a given program like:
Expand|Select|Wrap|Line Numbers
  1. #-----------------------------------------------------------------------------
  2. # main.pl
  3. # This program calls a second Perl program named 'called.pl' 
  4. # and pass one command line argument
  5. #----------------------------------------------------------------------------
  6. #!/usr/bin/perl -w
  7. use strict;
  8.  
  9. my $passThisArgument = "This is Perl world! \n!" ;
  10. my $cmd = qq@perl /home/pawan/Perl/called.pl $passThisArgument @;
  11. my $result = system($cmd);
  12.  
  13. print "Checking status...: $result \n";
  14. # Do other things...
  15. #---------- End of main.pl------------------------
  16.  
  17. #--------------------------------------------------------------------
  18. # Called.pl
  19. # This Program is called from another program main.pl 
  20. # with a command line argument
  21. #--------------------------------------------------------------------
  22. #!/usr/bin/perl -w
  23. use strict;
  24.  
  25. my $receivedArgument = $ARGV[0];
  26. print " Lets see what parameter was passed to this program...oh! it is: $receivedArgument \n";
  27.  
  28. # All remaining code
  29. #-----END of called.pl----------
Hope this will help you.

Regards,
Pawan
Aug 8 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.