At 7:26 PM 9/27/96, Jamie McCarthy wrote: >Here's the actual code I use [for outputing raw binaries to stdout]; > >sub print_file_raw >{ > if (-r $fpath and $size = -s $fpath) { > # > # shove another header in there, just for fun - > # some browsers make use of this > # > $ct .= "\nContent-length: $size"; > } > if (!open(FPATH, $fpath)) { > &print_file_cant_open(); > } else { > &print_content_type($ct); > while (read(FPATH, $buffer, 16384)) { > print $buffer; > } > } >} > >sub print_content_type >{ > local($ct) = @_; > $ct = "text/html" if !$ct; > print "Content-type: $ct\n\n"; >} Okay - this gives me a chance to ask another question... I'm having a bit of a rough time grasping calling subs and how values are passed and then returned to/from the subroutine. In the case above, there are no locals, but shouldn't $fpath, $size, and $ct be passed to the subroutine? Would it be called like so: #begin $fpath = ":images:pic.gif"; $ct = "image/gif"; $size = 12345; &print_file_raw($fpath, $ct, $size); #end ?? - I'm also trying to write a subroutine that takes a long string, and returns it split up into a hash. The way I want to call it is: %form = &splitter($longthing); If you haven't guessed, this is going to be used to split a CGI post into a hash. Everything I've seen just calls the subroutine, and the subroutine itself returns the %FORM stuff - I'd rather assign it in the main section of the program, where I can make the subroutine more portable, by being able to interchange above with something like %order = &splitter($submission); The perlsub manpage doesn't make much sense on this part. >Reading to and printing from a buffer of fixed size will give more >predictable results than "while ($image=<GIF>)". Is there any particular reason you used a 16k buffer? Was this just what worked best for your apps or is this an unwritten rule somewhere? It makes sense to use a buffer, but I'm still pretty much a newbie to Perl (and programming in general) so I use the path of least resistance -- which often turns out to also be the path of most confusion, problems, and bugs, I've learned ;-> I appreciate your help with this, Jamie. I'm slowly learning that Perl is amazingly powerful for even the simplest of jobs, both on Mac and Unix machines. Now, I know this is a bit off-topic, but does anybody know a good scriptable graphics pkg. Something that I can feed some simple data and have it create a graphic (a graph/chart, really) for the mac? Please reply via e-mail to keep the list free of more of my rantings ;-> [Daniel] ---------------------------------------------------------------------- Daniel Hedrick mailto:daniel@icorp.net ICorp http://www.icorp.net/ ---------------------------------------------------------------------- Sometimes the things I say represent ICorp, sometimes they don't...