Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Monks:
I am having problems saving some params to a file ( printing();)($file, look at the code). The funny thing is the when I run the code (>perl file.pl ) a file is created. This is what I get in the apache server error log "Cannot save file /var/www/html/datfiles/data.dat at /var/www/cgi-bin/results.pl line 48. ". Please help!
#file.pl #!/usr/bin/perl use strict; use CGI::Cookie; use CGI; my $cgi = new CGI; my $file = "/var/www/html/datfiles/data.dat"; print $cgi->header( -cookie => new CGI::Cookie(-name => 'Cho +colateChip', -value=> $cgi- +>param('color'), -expires => 'T +hu, 26-Sep-2002 00:00:00 GMT'#, #-domain => 's +tudents.byu.edu', #-path => '/' ) ); print $cgi->start_html(-title => 'Results', -bgcolor => $cgi->param('color')); if ($cgi->param()) { print $cgi->center( $cgi->h3("Hello: ". $cgi->param('name')), $cgi->p, "The keywords are: ",join(", ",$cgi->param('words')), $cgi->p, "Your favorite color is: ",$cgi->param('color')); } printing(); print $cgi->end_html(); sub printing { open(FILE, ">$file")|| die "Cannot save file $file "; print "test"; print FILE $cgi->param('name'); print FILE join(", ",$cgi->param('words')); print FILE $cgi->param('color'); close FILE; }

In reply to Cannot save to file with a CGI scipt by chuleto1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-18 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found