... 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.


In reply to Re: sending data thru a sub routine by AnomalousMonk
in thread sending data thru a sub routine by james28909

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.