Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

(jeffa) Re: perl + CGI's

by jeffa (Bishop)
on Dec 13, 2002 at 15:48 UTC ( #219611=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://219611]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2022-08-15 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?