bazz
02-21-2006, 09:00 PM
Feels like a simple error but I don't get it.
This code creates a Dir and is then supposed to open it and create files in it.
It fails at the point where it is meant to create the files. I am wondering if the script is running all the way through, which happens to be befor the server has opened the DIR? if this is possible, how tdo I make the script pause?
I tried the full Filepath as well as this shortened one but neither seems to work.
my $Filepath ="/domains/574/2317/html/cgi-bin/$clientsReservationsDir/Rooms_Booked/"; # location of where to open New Directory for $nextYear
opendir(my $dir,$Filepath) or die "You have been unsuccessful. The Directory has not been opened.\n";
chdir "Rooms_Booked";
mkdir "$nextYear";
print "next year = $nextYear\n";
opendir(my $dir,"$Filepath$nextYear/") or die "Uh Oh! $Filepath$nextYear/ You have been unsuccessful. The Directory has not been opened. To repeat the process, remember to refresh the page\n";
foreach my $Month (sort values %months) {
#print "month =$Month<br />\n"; #successful
foreach $Date (sort values %dates) {
if ($Month == '09' || $Month == '04' || $Month == '06' || $Month == '11' ) {
if ($Date > 30 ){
next;
}
}
if ($Month == 02 && $Date > '29' ) {
next;
}
if ($Month == 02 && $yearDivided =~ m/\./ && $Date > '28' ) {
next;
}
$YMD = join ("-", ($nextYear, $Month, $Date));
foreach ( qw( SingleRoomNumbers DoubleRoomNumbers TwinRoomNumbers FamilyRoomNumbers SuitesRoomNumbers ) ){
$type = $1 if $_ =~ /^(.*?)RoomNumbers/;
@rooms = split ',', $accommodations{$_};
foreach $room (@rooms) {
print join ('_', ($type, $room, $YMD )), $/;
my $filenames = join ('_', ($type, $room, $YMD)), $/;
my $dat_file ="$filenames";
print "df=$dat_file<br />\n"; #prints OK
open DAT, "< $dat_file" || die "couldnt open file\n";# doesn't even output the error here.
}
}
}
}
Almost embarrassed to ask for help with this one :o
Bazz
This code creates a Dir and is then supposed to open it and create files in it.
It fails at the point where it is meant to create the files. I am wondering if the script is running all the way through, which happens to be befor the server has opened the DIR? if this is possible, how tdo I make the script pause?
I tried the full Filepath as well as this shortened one but neither seems to work.
my $Filepath ="/domains/574/2317/html/cgi-bin/$clientsReservationsDir/Rooms_Booked/"; # location of where to open New Directory for $nextYear
opendir(my $dir,$Filepath) or die "You have been unsuccessful. The Directory has not been opened.\n";
chdir "Rooms_Booked";
mkdir "$nextYear";
print "next year = $nextYear\n";
opendir(my $dir,"$Filepath$nextYear/") or die "Uh Oh! $Filepath$nextYear/ You have been unsuccessful. The Directory has not been opened. To repeat the process, remember to refresh the page\n";
foreach my $Month (sort values %months) {
#print "month =$Month<br />\n"; #successful
foreach $Date (sort values %dates) {
if ($Month == '09' || $Month == '04' || $Month == '06' || $Month == '11' ) {
if ($Date > 30 ){
next;
}
}
if ($Month == 02 && $Date > '29' ) {
next;
}
if ($Month == 02 && $yearDivided =~ m/\./ && $Date > '28' ) {
next;
}
$YMD = join ("-", ($nextYear, $Month, $Date));
foreach ( qw( SingleRoomNumbers DoubleRoomNumbers TwinRoomNumbers FamilyRoomNumbers SuitesRoomNumbers ) ){
$type = $1 if $_ =~ /^(.*?)RoomNumbers/;
@rooms = split ',', $accommodations{$_};
foreach $room (@rooms) {
print join ('_', ($type, $room, $YMD )), $/;
my $filenames = join ('_', ($type, $room, $YMD)), $/;
my $dat_file ="$filenames";
print "df=$dat_file<br />\n"; #prints OK
open DAT, "< $dat_file" || die "couldnt open file\n";# doesn't even output the error here.
}
}
}
}
Almost embarrassed to ask for help with this one :o
Bazz