[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] dumping to file



Strider writes:
|>is there a way i can dump all the html i am printing through macperl to a
|>file instead of to the screen?
|open (OUT ">$somefile");
|print OUT $htmldata; # instead of print $htmldata;
|close OUT;
|and that's it. if you print <<ht_ml; just print OUT <<ht_ml; .

If you just want to dump to a file temporarily, you can:

open STDOUT, ">somefile" || die ...;

and then you don't have to go through your code and change all prints,
printfs, writes, selects, file handle saves, etc. To go back to not
dumping to a file, just comment out or remove the open.

You can also use this to dump to a file based upon some condition:

if (!$running_under_web_server)
{
	open STDOUT, ">somefile" || die ...;
}

If you want to do this just in one section of code, try:

open SAVOUT, ">&STDOUT";
open STDOUT, ">somefile";

do some stuff that prints to STDOUT

close STDOUT;
open STDOUT, ">&SAVOUT";

Brian

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch