I am trying to figure out whether there is a matching folder under a different part of the directory tree and then whether there is a .pdf file in that folder. The "ALLFILES" contains pdf files (a resource fork from OSX and the "real" file). I have not cleaned up the ALLFILES to include just 1 copy of the file, but you can see below I get different results for each even though they data I am stripping from the files paths is the same. Am I not understanding something about the glob function in perl? I very rarely use perl or program so forgive me

#!/usr/bin/perl use File::Glob qw(:globally :nocase); my $PROGDIR = "/home/jchase/espresso/"; my $ALLFILES = "$PROGDIR"."ALL.txt"; my $INELIGIBLE = "$PROGDIR"."INELIGIBLE.txt"; my $INELIGIBLE_NO_FOLDER = "$PROGDIR"."INELIGIBLE_NO_FOLDER.txt"; my $INELIGIBLE_NO_PDF = "$PROGDIR"."INELIGIBLE_NO_PDF.txt"; my $ELIGIBLE = "$PROGDIR"."ELIGIBLE.txt"; my $DEBUG = "$PROGDIR"."DEBUG.txt"; #Open the eligible file list open(FILE, "$ALLFILES") or die("Error reading $ALLFILES."); #Open this file for debug information open(DEBUG, ">>$DEBUG") or die("Error reading #DEBUG."); #Loop through the eligible file list and determine if there is a #matching folder in the INTERIORS archive folder structure while ( ! eof(FILE) ) { $FULLNAME = readline( *FILE ); print DEBUG "Working with $FULLNAME"; #Split the array on the folder levels via "/" @FULLARRAY = split(/\//,$FULLNAME); #Recontrsuct the folder name while substituting COVERS archive #into INTERIORS archive. This is to find out if that folder ex +ists $INTERIORNAME = "/".$FULLARRAY[1]."/".$FULLARRAY[2]."/"."INTER +IORS archive"."/".$FULLARRAY[4]."/".$FULLARRAY[5]."/"; print DEBUG "Looking for $INTERIORNAME\n"; if ( ! -d "$INTERIORNAME" ) { open(LOG,">>$INELIGIBLE_NO_FOLDER") or die("Error reading $INELIGIBLE_NO_FOLDER"); print DEBUG "Did not find folder! Printing to Ineligib +le_no_folder\n\n"; print LOG "$FULLNAME"."\n"; close LOG; } else { print DEBUG "Found the folder, is there a PDF?\n"; #Time to find out if there is a PDF in the folder if ( ! -e <"$INTERIORNAME"*.pdf> ) { open(NOPDF,">>$INELIGIBLE_NO_PDF") or die ("Error reading $INELIGIBLE_NO_PDF +"); print DEBUG "There is no PDF in here! Printing + to Ineligible_no_pdf\n\n"; print NOPDF "$INTERIORNAME"."\n"; close NOPDF; } else { open(ELIG,">>$ELIGIBLE") or die ("Error reading $ELIGIBLE"); print DEBUG "FOUND A PDF! Printing to ELIGIBLE +!\n\n"; print ELIG "$INTERIORNAME"."\n"; close ELIG; } } } close(FILE);

And here is some DEBUG output that shows why this isn't working and I am confused. Basically the ._*.pdf file will give the correct output and the "real" file evaluation will never find a pdf. The folder check always works correctly:

Working with /local/Macintosh/COVERS archive/A-E/Alchemists Mediums and Magicians-PB/._Alchemists Mediums Magicians.pdf

Looking for /local/Macintosh/INTERIORS archive/A-E/Alchemists Mediums and Magicians-PB/

Found the folder, is there a PDF?

FOUND A PDF! Printing to ELIGIBLE!

Working with /local/Macintosh/COVERS archive/A-E/Alchemists Mediums and Magicians-PB/Alchemists Mediums Magicians.pdf

Looking for /local/Macintosh/INTERIORS archive/A-E/Alchemists Mediums and Magicians-PB/

Found the folder, is there a PDF?

There is no PDF in here! Printing to Ineligible_no_pdf


In reply to trouble with glob by kurt2439

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.