I can open a file using "open(F,"19150009212005.txt");"
I also one variable : $date=09212005
How can I open the file using this variable? I tried:
open(F,"191500/$date/.txt"); It did not work.
Your string would interpolate as: "191500/9212005/.txt" so not only are you miss the zero but you have a filename of ".txt". Is that really what you want?
I think not.
Code:
my $date = "09212005";
my $pathname = "191500/$date.txt";
open F, $pathname or die "Failed to open $pathname";
Sorry I did not address clearly. Folloing is my code:
my $date=@data[1]; (@data[1] contains "09222005" got from web CGI)
my $pathname = "191500$date.txt";
print "$date<br>\n";
print "$pathname<br>\n";
open(F,$pathname);
It did not work. But I got the print outputs;
09222005
19150009222005.txt
Why I still can not open this file?
But the following codes worked:
my $date = "09222005";
my $pathname = "191500$date.txt";
open(F,$pathname);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.