opening a file problem

i try to open a file in a perl script and this works...
open FILE,'<correct.txt' or die "can't open correct.txt because $!";

however when i pass the scipt the value 1.txt as a QUERY_STRING
like this
<a href="http://....cgi-bin/test.cgi?1.txt>click here</a>

and try....
open FILE,'</data/local/apache/htdocs/answers/$ENV{QUERY_STRING}' or die "can't
open /data/local/apache/htdocs/answers/$ENV{QUERY_STRING} because $!";

it wont work!!!
the error it reports is

can't open /data/local/apache/htdocs/answers/291119991.txt because No such file
 or directory at /usr/local/apache/cgi-bin/test.cgi line 46, <FILE> chunk 1

but the file is there and i have done chmod correctly (as far as i know)

can anyone help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

# Change your href to say ?file=1.txt

my $querystr = $ENV{"QUERY_STRING"};
my @queries = split (/&/, $querystr);

for (my $query=0; $query <= $#queries; $query++)
  my ($name, $value) = split (/=/, $queries[$query]);
  $querystring{$name} = $value;

open infile, "<$querystring{'file'}";
  @lines = <infile>;
  print @lines;
close infile;

# Try that

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The problem is possibly that your QUERY_STRING likely has a trailing newline, if you do a "chomp $ENV{QUERY_STRING}" prior to trying to use the variable it should work...

open FILE,'</data/local/apache/htdocs/answers/$ENV{QUERY_STRING}' or die "can't
open /data/local/apache/htdocs/answers/$ENV{QUERY_STRING} because $!";

....or optionally what binkzz said should work too.
Rocca - Seeing you're not vey customed to Experts Exchange you might want to read the rules first.

It's uncustom and very inconvenient to answer a question rather than just supply your comment. You say it's 'possibly' an answer so why post it as one? Comments can be accepted as answers so you don't have to be afraid of losing out.

Besides that, prematurely answering will take the question away from other experts to have a look at as it's status will be locked.
paddytsrAuthor Commented:
binkzz got there first
hes right about locking up questions with answers too
thanks binkzz
Binkzz - thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.