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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.