ikkon has asked for the wisdom of the Perl Monks concerning the following question:
Any Ideas what I am doing wrong?#!/usr/bin/perl BEGIN { use CGI::Carp qw(carpout confess); open(LOG, ">>","Entrance.log") or die("Unable to open mycgi-log: $!\n"); carpout(LOG); } #$SIG{__DIE__}; #$SIG{__WARN__}; use CGI qw(:standard); use strict; my $RoomName = 'Entrance'; my $CSS_Name = qq{$RoomName.css}; if (param('cssScript')) { write_file($CSS_Name, param('cssScript')); } my @CSS_Array = read_file($CSS_Name); my $CSS_script = join("\n", @CSS_Array); print header; print start_html("$RoomName Edit"), h1("$RoomName CSS"), start_form; print textarea(-name=>'cssScript', -default=>$CSS_script, -rows=>50, -columns=>75); print p, submit, end_form, hr; print end_html; sub read_file { my ( $f ) = @_; open F, "< $f" or die "Can't open $f : $!"; my @f = <F>; close F; return wantarray ? @f : \@f; } sub write_file { my ( $f, @data ) = @_; @data = () unless @data; open F, "> $f" or die "Can't open $f : $!"; print F @data; close F; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI parse and edit file
by ww (Archbishop) on Feb 29, 2008 at 02:39 UTC | |
by ikkon (Monk) on Feb 29, 2008 at 04:46 UTC | |
by moritz (Cardinal) on Feb 29, 2008 at 08:05 UTC | |
by proceng (Scribe) on Feb 29, 2008 at 13:13 UTC |