in reply to sending data thru a sub routine
... when i run this script there will be two files that i will be run through this to extract and check data. What i really want to know is if i can use $ARGV[0] for both files if i run them through the subroutine one at a time.
I don't understand this. Do you mean that you will invoke the script twice, with a different file name given each time:
system_prompt>perl your_script.pl file_1
system_prompt>perl your_script.pl file_2
passing a single file name string to the infile() subroutine on each script invocation? Or do you want to invoke the script with two file names at once:
system_prompt>perl your_script.pl file_1 file_2
and process both files during one invocation of the script?
In the first case, two separate invocations of the script, using $ARGV[0] for the file name is fine. In the second case, a single invocation with two file names, you need to realize that the two strings representing the file names will end up in $ARGV[0] and $ARGV[1] respectively, and you must process these two elements of the @ARGV array independently and re-organiize the logic of your script accordingly.
Update: Finally realized that most Perl scripts are invoked not as
script_name.pl parameter_1 param_2 ...
but as
perl script_name.pl parameter_1 param_2 ...
and changed the command-line (pseudo-)code examples above accordingly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sending data thru a sub routine
by james28909 (Deacon) on May 11, 2014 at 19:15 UTC | |
by kcott (Archbishop) on May 11, 2014 at 21:16 UTC | |
by james28909 (Deacon) on May 12, 2014 at 01:54 UTC | |
by Laurent_R (Canon) on May 11, 2014 at 21:02 UTC | |
by james28909 (Deacon) on May 12, 2014 at 01:44 UTC | |
by Laurent_R (Canon) on May 12, 2014 at 06:15 UTC | |
|
Re^2: sending data thru a sub routine
by james28909 (Deacon) on May 14, 2014 at 02:01 UTC |