| | |
Call perl script with a variable
![]() |
•
•
Join Date: Dec 2007
Posts: 17
Reputation:
Solved Threads: 0
Although it sounds pretty simple, i haven't found a proper answer for this issue.
I want to know how can i call a perl script and pass a variable to it.
For example, lets say "Parse.pl" is a parsing script of some sort and i want to call it from another perl script, or from a command line, with a variable: Parse($line);
Parse.pl will get the variable $line, perform parsing on it and return it to the main script (the return part is not really important);
Any idea how its done?
I want to know how can i call a perl script and pass a variable to it.
For example, lets say "Parse.pl" is a parsing script of some sort and i want to call it from another perl script, or from a command line, with a variable: Parse($line);
Parse.pl will get the variable $line, perform parsing on it and return it to the main script (the return part is not really important);
Any idea how its done?
Hi,
I would recommend you to define a method in Parse.pl and use it in your client script which requires parsing. For eg.
Note: In Parse.pl define only methods, because when you
hope this helps.
katharnakh.
I would recommend you to define a method in Parse.pl and use it in your client script which requires parsing. For eg.
#caller.pl require 'Parse.pl'; #... # call method parse_me(for eg.) in Parse.pl my $return_val = Parse::parse_me($line); #...
#Parse.pl
sub parse_me{
my $line = @_;
#...
}
1;require something, perl will try to execute that script first and then subsequent lines following require line.hope this helps.
katharnakh.
•
•
Join Date: Feb 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
Although it sounds pretty simple, i haven't found a proper answer for this issue.
I want to know how can i call a perl script and pass a variable to it.
For example, lets say "Parse.pl" is a parsing script of some sort and i want to call it from another perl script, or from a command line, with a variable: Parse($line);
Parse.pl will get the variable $line, perform parsing on it and return it to the main script (the return part is not really important);
Any idea how its done?
you get the command line values in the @ARGV array which you can run through in a loop.
![]() |
Similar Threads
- Calling one Perl script from another - HELP!!! (Perl)
- modify script (Perl)
- Log file rotation script (Perl)
Other Threads in the Perl Forum
- Previous Thread: Help - Install XML-LibXML on windows
- Next Thread: perl assignment question
| Thread Tools | Search this Thread |





