hello oxalate and welcome to the monastery and to the wonderful world of Perl!

You already are on the right path ( strict and warnigns are there ) but maybe you need to use some idioms more: firstly the use of the better form to open a file: lexical filehandle, checking if all was good: open my $h, '<', $file or die "cannot read from $file!"

Another common way, idiomatic way of Perl thinking is: uniqueness, quantity or existence of something lead immediately to use an hash. You read a list populating the hash with each item and later on you'll be able to check against this list as simply as:  .. if exists $files{$current_element}

But given your numbers (300 files is not a big deal nowadays..) you can also do all the work directly while reading the list file:

.. my $list_file = '/path/to/list.txt'; open my $read, '<', $list_file or die "cannot read from'$list_file'!"; while (<$read>){ # it populates $_ is the same of: defined $_ = <$rea +d> chomp; my $ret = process ($_) if -e "./$_"; if ($ret){print "$_ succesfully processed\n"} else{print "Warning: '$_' was not processed!\n"} } sub process{ my $file = shift; open ... or return 0 # read and do something close .. # implicitly return the last thing: if close succeded is 1 }

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Parsing files in a directory using a list. by Discipulus
in thread Parsing files in a directory using a list. by oxalate

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.