Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: saving cgi output as html

by katgirl (Hermit)
on May 30, 2003 at 12:59 UTC ( #261841=note: print w/ replies, xml ) Need Help??

in reply to saving cgi output as html

What arthas said, except you may want to change the name of the file if the data is different each time and you want to keep it. Like so:

my $filename = time(); my $doc = ''; open (MYOUT, ">/mypath/$filename.html") or die $!; $doc .= "<p>Mydata....</p>"; $doc .= "<p>Myotherdata....</p>"; print $doc; # This goes to the web browser print MYOUT $doc; # This goes to a files close (MYOUT);
You may also want to add a piece of code to clear out the old files after a specified number of days:
my(@files, $file); opendir(DATADIR, "datadir"); @files = grep(/[0-9].html/,readdir(DATADIR)); closedir(DATADIR); foreach $file (@files) { if (-M "data/$file" > 30) { unlink("data/$file"); } }

Comment on Re: saving cgi output as html
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-11-27 08:49 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (722 votes), past polls