CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
a file exists progam

 



smart000
New User

Sep 2, 2008, 8:19 PM

Post #1 of 2 (532 views)
a file exists progam Can't Post

1. read a .txt file which lists file names (without dir path) to be checked

2. The files present in (1) should be present in the folder to be scanned

3. Have hardcoded variables to get a working version. The filename get displayed correctly, however the check fails.

Thanks in advance.


use strict;
my $file_run_order = 'C:\Tech\perl_programs\check_files\IBA_BA_TEST\RUN_ORDER.txt';
my $work_dir = 'C:\Tech\perl_programs\check_files\IBA_BA_TEST\\';
my $file_to_check = "test";
my $all_well_flag = "1";


open(FILE,$file_run_order) || die "cannot open file !!";
chdir("C:\Tech\perl_programs\check_files\IBA_BA_TEST");

while(<FILE>){
my $file_to_check = $_;

chomp($file_to_check);
print ($file_to_check);

print $work_dir.$file_to_check;

if (-e "$work_dir.$file_to_check"){
#if (-e "$file_run_order"){
print " -- EXISTS \n";
}
else{
print " -- NOT present \n";
}
}

close(FILE);


travs69
Novice

Sep 2, 2008, 8:26 PM

Post #2 of 2 (529 views)
Re: [smart000] a file exists progam [In reply to] Can't Post

hdir("C:\Tech\perl_programs\check_files\IBA_BA_TEST");

should be single quotes instead of double quotes

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives