R
Robert
Hi,
I am having trouble opening a file where a variable is used in the file name
reference. Here is the non functional code:
my $location = "smith";
open (FH, "<../clients/$location/overview.txt") or die "Can't open the file:
$!";
my @overview = <FH>;
close(FH);
print @overview;
This code DOES work:
#my $location = "smith";
open (FH, "<../clients/smith/overview.txt") or die "Can't open the file:
$!";
my @overview = <FH>;
close(FH);
print @overview;
Above I manually added the directory name to find the file and commented out
the first variable definition. I beleive that somehow I need to distinguish
$location from the rest of the file name location but am not sure how that
is accomplished. I tried: open (FH, "<../clients/$location\/overview.txt")
but that didn't work either. TIA!
Robert
I am having trouble opening a file where a variable is used in the file name
reference. Here is the non functional code:
my $location = "smith";
open (FH, "<../clients/$location/overview.txt") or die "Can't open the file:
$!";
my @overview = <FH>;
close(FH);
print @overview;
This code DOES work:
#my $location = "smith";
open (FH, "<../clients/smith/overview.txt") or die "Can't open the file:
$!";
my @overview = <FH>;
close(FH);
print @overview;
Above I manually added the directory name to find the file and commented out
the first variable definition. I beleive that somehow I need to distinguish
$location from the rest of the file name location but am not sure how that
is accomplished. I tried: open (FH, "<../clients/$location\/overview.txt")
but that didn't work either. TIA!
Robert