in reply to Re^2: sending data thru a sub routine
in thread sending data thru a sub routine

I think that you are somewhat confused. You can do either of two (or possibly more) things: 1. Launch your script only once, with the two files as arguments, and process each argument one after the other with the same subroutine; or 2. launch the script twice, each time with only one argument. Both approaches are valid, it is up to you to decide how you want to do it, but I would personally tend to favor the first approach (this enables to take into account things that happened while reading the first file when reading the second one, which would be much more difficult with the second solution). The first solution could more or less look as follows:
perl process_files.pl file1.txt file2.txt
and, inside the program:
for $inputfile (@ARGV) { process_file ($inputfile); }
The second approach would probably require a shell script under Un*x, or *.bat command script under Windows (or *.com command file under VMS, or whatever with other OS's) to loop over the two filenames. One of the advantages of the first approach is that it can be more portable across platforms.

Replies are listed 'Best First'.
Re^4: sending data thru a sub routine
by james28909 (Deacon) on May 12, 2014 at 01:44 UTC
    but see, i wont know the file until i parse the main file. The file you looked at before in the other thread is part of another file, its a table within a table within a table.
    psuedocode: open main file for parsing; #not file1 or file2 parse out each file within this file; when reach $file1 send to subroutine; when reach $file2 send to subroutine; exit script;
    its hard to explain actually lol. All the files will be handled basically the same way as this subroutine above but will be a little bit different.
    The Main File has around 60 files inside of it. when you open the file in any hex editor... it has references just like the file i think you looked at a few days ago with file 1-25. the main thing with this script is will it allow me to go to $file1 and send it thru the sub routine, then go to $file2 and then send it thru the subroutine.

    TL;DR
    In essence these two files are within another file that i am parsing via hex offsets. i want to send each file thru one at a time in the same script.
    so i think this will work correct? :
    my $file1 = 'extracted/file1'; sub infile($file1); my $file2 = 'extracted/file2'; sub infile = 'extracted/file2';
      Then we are talking about something much closer to the first approach I was mentionning. You basically need to read the first file, collect and store in an array (or some other data structure) the names of the files to be processed, and then process each of these files. And a subroutine is really necessary to avoid code duplication.