download script for video files

Hi ! I want to write a script which makes it possible for the user to download special files, which normally would be opened by the web server. This is my solution, but the script just downloads
parts of files.... (mostly about 400 Bytes)

#! perl

  $x = $ENV{'PATH_INFO'};
  @values = split(/\&/,$x);
  ($dname,$trash)  = split(/&/,@values[0]);
  ($trash,$dname)  = split(/download\.pl/,$dname);
  ($trash,$endung) = split(/\./,$dname);

  $dname = '/www/milleniumserver/videotrading'.$dname;
#$dname =~ s/\//\\/g;

  open  (FILE, $dname) or &fehler;
  print "Content\-type\: application\/$endung\n\n";
  print join('',<FILE>);
  close (FILE);

  open  (STAT, '>>download.log');
  ($sek,$min,$std,$tag,$mon,$jahr) = localtime(time);
  print STAT "downloaded\: $dname\; $std\:$min\:$sek \/ $tag\.$mon\.$jahr\n";

sub fehler
  print "Content-type:text/html\n\n";
  print "\<h1\>Fehler \! Datei konnte nicht ge\ö\;ffnet werden \! \($dname\)";

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.

ItsMeAuthor Commented:
Edited text of question.
Depending on what operating system you're on, you may need

And you don't need to \quote - < > ! ( ) . in qq strings
ItsMeAuthor Commented:
binmode ??? What di I have to change in the source ?

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

open (FILE, $dname) or &fehler;
binmode FILE;
binmode STDOUT;
print "Content-type: application/$endung\n\n";
print <FILE>;
close (FILE);

but that can be very dangerous if the client sends a PATH_INFO containing something like ' ; delete *.*|'

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
ItsMeAuthor Commented:
why is it dangerous ? tell me. i'm new in perl. does the open command executes system commands ???
yes, see
perldoc -f open
A simple way to protect yourself from trying to open a system command would be to say:
  open(FILE, "<$dname") or &fehler;  

and by the way,cc
perl -Mdiagnostics -wc
($dname,$trash)  = split(/&/,@values[0]);
Scalar value @values[0] better written as $values[0] at - line 1 (#1)
    (W) You've used an array slice (indicated by @) to select a single element of
    an array.  Generally it's better to ask for a scalar value (indicated by $).
    The difference is that $foo[&bar] always behaves like a scalar, both when
    assigning to it and when evaluating its argument, while @foo[&bar] behaves
    like a list when you assign to it, and provides a list context to its
    subscript, which can do weird things if you're expecting only one subscript.
    On the other hand, if you were actually hoping to treat the array
    element as a list, you need to look into how references work, because
    Perl will not magically convert between scalars and lists for you.  See
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.