in reply to Range File Open

If you have an array of files:
for my $x_file (@files){ my $xp = XML::XPath->new(filename => $x_file); # continue as before }

Replies are listed 'Best First'.
Re^2: Range File Open
by Anonymous Monk on Mar 04, 2008 at 14:24 UTC
    OK, but how can I pass the range of files to be open to this array?

      You already have some code to scan through your directory and decide whether or not you want a file, so all you have to do is push the file into the array at the end of a similar loop. Something like the following:

      while (my $file = readdir(DIR)) { #decide whether or not this is a file the user wants ... push @files, $file; }

      Then you can use stiller's loop to iterate through that list, opening each file for processing.

        How to get the range, lets say, in this directory I have 30 files, from day 1 to day 30, form this dropdown menu I select from day 5 to day 25, and then do the processing, open all the files between day 5 and day 25, how can I do that on this code?
      Edit: amarquis idea is better than the following, I didn't look through your code to notice what he saw....

      you could use

      my @files; if (-d $x_file) { # $x_file is a directory, not a file @files = glob "$x_file/*xml"; } elsif ($x_file =~ /xml$/ and -e $x_file){ # $x_file is an xml-file, and we have access to it push @files, $x_file; } else { die("can't make sense out xml-directory or xml-file $x_file"); }
      Or File::Glob, File::Find, ...