I am creating a script which when given a date range, will grab certain files created during those dates, in order to determine what differences exist, if any. I was planning on using Array::Compare to make my comparisons.

Here is some code:
#!/usr/local/bin/perl use strict; use Array::Compare; ############################## # Define some variables here # ############################## my ( @pub, @priv, @as, @files, @lines ); my ( $num, $from, $to, $AS, $privstring, $pubstring, $element, $beg_priv_file, $beg_pub_file, $comp_file, $as_dir, $line ); my $dir = "path-to-peering-files"; ################### # test invocation # ################### die "\nUsage: $0 <AS> <yyyymmdd-yyyymmdd>\n This program will take peering files, as per AS specified on the command line where AS = [123, 456, 789, 111, 222] choose multiple AS's by comma-separating them for example, \"123,456,789\" -a to process all valid AS's\n\n" unless @ARGV; unless (($from, $to) = $ARGV[1] =~ /(\d{8})-(\d{8})/) { die "Invalid dates or date format\n"; } unless ($from < $to){ die "Invalid date range\n"; } $AS = $ARGV[0]; my @as = split(",", $AS); foreach $num(@as){ die "AS $num is not recognized. Please choose [123, 456, 789, 111, 222]\n" unless ($num == 123 || $num == 456 || $num == 789 || $num == 111 || $num == 222 || $num == "-a"); } ######################### # Set AS(s) to process # ######################### if ($AS == "-a"){ @as = qw(123 456 789 111 222); } ############################## # Begin file processing here # ############################## foreach $num(@as) { &get_routers($num); } ############### # SUBROUTINES # ############### sub get_routers { #################################### # set file prepend according to AS # #################################### if ($num = "123") { $privstring = "private-peering."; $pubstring = "public-peering."; $as_dir = "$dir/AS$num"; } elsif ($num = "456") { $privstring ="global-public-peering."; $pubstring = "global-private-peering."; $as_dir = "$dir/AS$num"; } elsif ($num = "789") { $privstring = "ebiz-public-peering."; $pubstring = "ebiz-private-peering."; $as_dir = "$dir/AS$num"; } elsif ($num = "111") { $privstring = "euro-public-peering."; $pubstring = "euro-private-peering."; $as_dir = "$dir/AS$num"; } else { $privstring = "asia-public-peering."; $pubstring = "asia-private-peering."; $as_dir = "$dir/AS$num"; } } opendir (DIR, $as_dir) || die "Cannot open $as_dir: $!.\nRestart this program without AS$AS, or go find out what's wrong, and re-run the program.\n"; @files = grep { /(\d{8})/ && $1 >= $from && $1 <= $to } readdir DIR; ############################################### # push private-peering files into an array, # # and public-peering files into another array # ############################################### foreach my $t(@files){ if ($t =~/^$privstring(\d+$)/){ push(@priv, $t); } elsif ($t =~/^$pubstring(\d+$)/){ push(@pub, $t); } } $beg_priv_file = shift(@priv); $beg_pub_file = shift(@pub); open (BEG_PRIV_FILE, "$as_dir/$beg_priv_file") || die "Cannot open: $!\n"; LINE: while (<BEG_PRIV_FILE>){ chomp; if (/unknown/) { next LINE;} elsif (/shutdown/) { next LINE;} @lines = $_; }
This is where I am stuck. I don't know how to open each of the other files in  @priv and  @pub and write them to dynamically created arrays; one for each file. And, as I'm writing this I just realized that in order to be accurate, I will need to:
now this is pseudo-code, so don't bash me here! if $element(@beginning_file) doesn't exist in @next_file Print something to STDOUT that I will define later. AND if $element(@next_file) doesn't exist in @beginning_file Print something else to STDOUT that I will define later
I'm really stuck. Can anyone help me out?

In reply to Arrays of files from an array of file names by Tuna

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.