in reply to perl + CGI's
One problem you have is you are opening the file that you
are supposed to be reading in write mode in the second
example. That's not good. :)
Second, use File::Basename to get the basename (and don't forget your header!):
use strict; use CGI qw(:standard); use File::Basename; my $file = param('file'); my $name = fileparse($file); print header; if (open (FILE, $name)) { my $data = do {local $/; <FILE>; }; print $data; } else { print "can't open '$name'"; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
---|
In Section
Seekers of Perl Wisdom