#!/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 exists $INTERIORNAME = "/".$FULLARRAY[1]."/".$FULLARRAY[2]."/"."INTERIORS 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 Ineligible_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);