Did you actually test that your regex would deal with spaces in the file name? I think not. \w+ will not match a space, only [0-9a-zA-Z_]. A demo of different regex:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %keepList; while (my $line = <DATA>) { my $sdf_file; next unless ($sdf_file) = $line =~ /([\w ]+\.nfo)/; $keepList{$sdf_file} = 1; print "keeping \"$sdf_file\"\n"; #update for debugging ####### } =example printout keeping "filename1.nfo" keeping "filename2.nfo" keeping "file name2.nfo" keeping "file name3.nfo" keeping "file name4.nfo" =cut __DATA__ fullpath="C:\directory\filename1.nfo" id="1a" fullpath="C:\directory\filename2.nfo" id = "nonsense" fullpath = "C:\directory\file name2.nfo" fullpath = "C:/directory/file name3.nfo" fullpath = "C:\directory/file name4.nfo"
Your code:
my @files = $files; opendir(OUTPUT, $files); @files = grep {$_ ne '.' and $_ ne '..'} readdir(OUTPUT); closedir(OUTPUT);
better written? as:
opendir(OUTPUT, $files) or die "unable to opendir $!"; my @files = grep {-f $files/$_} readdir(OUTPUT); closedir(OUTPUT);
The -f file test excludes not only the "." and ".." directories but also other ones that might exist.
my @files = $files; does nothing useful.

Overall, great job at getting something to "work". In the scheme of things, my comments are just nits.


In reply to Re^5: Compare 2 arrays by Marshall
in thread Compare 2 arrays by niceguy

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.