hello, I have a problem with the parameter passing mechanism among 2 subroutines. my code is as follows.
I have 2 subroutines. the first one takes 2 parameters from command line:
* text file name containing file list
* file format
then it reads the given file, and fetches individual file names (with full path).
then it passes a file path and format to second subroutine called test_format. but these parameters becomes "unreadable" from the array object containing parameters, when I try to convert this array to an hash object (args2hash). because when I print the array object, it gives this output.
"/abc/def/xyz.dat format dat"
Actually it should be like this:
"input /abc/def/xyz.dat format dat"
The "input" keyword is missing.
What should I do?
sub test_filelist_format { my $obj = shift; my $args = Parser::args2hash (@_); my $input = $args->{'input'}; my $format = $args->{'format'}; if (!$input || !$format) { die("input file or format missing!\n"); } ## if not list readable, return -1 if ( $obj->is_readable(file=>$input) < 0 ) {return -1} ... my $formatstatus = test_format ("input" => $line, "format" => $for +mat); ... } sub test_format { my $obj = shift; my $args = Parser::args2hash (@_); my $input = $args->{'input'}; my $format = $args->{'format'}; my $gzip = $args->{'gzip'}; my $columns = $args->{'columns'}; if (!$input || !$format) { die("input file or format missing!\n"); } if ( $obj->is_readable(file=>$input) < 0 ) {return -1}; ... }
In reply to parameter passing problem by gokhan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |