Gossamer Forum
Home : General : Perl Programming :

test for file exist not working

Quote Reply
test for file exist not working
i want to print file size and number of records in db files. i'm opening each cfg file in data_path and reading the name of the db file from cfg file. excerpt of code below:
Code:
open (CONFILE, "<$db_data_path/$file") or &cgierr ("unable to open: $file.\nReason: $!");

while (<CONFILE>) {
if (/\$html_title/) {
$_=~s/\$html_title//g;
$_=~s/[=';]//g;
$_=~s/\#.*$//g; #3/11/2008 remove comments

$info_name = qq|$_|;
$info_link = qq|<a href="$dbman_script_url?db=$cfgfile&uid=$db_uid">Go to $cfgfile database</a> |;
}
if (/\$db_file_name/) {
$_=~s/\$db_file_name//g;
$_=~s/[=';]//g;
$_=~s/\#.*$//g;
$db_file = $_;
$db_file =~ s/\$db_data_path/$db_data_path/g;
$db_file =~ s/\$db_script_path/$db_script_path/g;
$db_file =~ s/"//g;
$db_file =~ s/ . //g;
$db_file =~ s/ //g;
}
}
close (CONFILE);

# size of the data file

if (-e $db_file) {
open (DBFILE, $db_file) or &cgierr ("unable to open: $db_file.\nReason: $!");
if ($db_use_flock) {
flock(DBFILE, 1) or &cgierr("unable to get exclusive lock on $db_file.\nReason: $!");
}
if ($size = -s $db_file){
blah blah blah
nothing in the if (-e $db_file) is being executed. i printed the value of $db_file and it is correct showing the complete path from the root. i have another sub that will open a file and display content. i sent $db_file to that link and it displays correctly. i can't figure out what's wrong!
Subject Author Views Date
Thread test for file exist not working delicia 4326 May 25, 2018, 11:17 AM
Post Re: [delicia] test for file exist not working
delicia 4281 May 25, 2018, 11:20 AM
Thread Re: [delicia] test for file exist not working
Andy 4275 May 26, 2018, 12:59 AM
Thread Re: [Andy] test for file exist not working
delicia 4268 May 26, 2018, 6:12 AM
Thread Re: [delicia] test for file exist not working
delicia 4265 May 26, 2018, 6:29 AM
Thread Re: [delicia] test for file exist not working
delicia 4264 May 26, 2018, 6:53 AM
Thread Re: [delicia] test for file exist not working
Andy 4257 May 27, 2018, 1:16 AM
Thread Re: [Andy] test for file exist not working
delicia 4235 May 28, 2018, 8:36 AM
Post Re: [delicia] test for file exist not working
Andy 4220 May 28, 2018, 11:06 PM