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

Re: [MacPerl] Droplet to make CGI?



OK, I got this to work.  But (isn't there always a but) I ran into a
problem with the set method from the Mac::Memory module.

The code I'm using (stolen from the MacPerl book) is
 	OpenResFile ($newfile);
 	$res = Get1Resource('TEXT', 128);
 	if ($res) {
 		$res->set(0,1,$script);
 		ChangedResource($res);
 		UpdateResFile(CurResFile());
 		ReleaseResource($res);
 	} else { warn ($^E) }
 	CloseResFile(CurResFile());


I found the following:
If I created a cgi file with nothing in the TEXT resource, set would not
insert the the contents of $script into the resource.

If I added any character, it would work.

Is this expected behavior?

Also, Chris mentioned tracking the current position of inserted data in
order to insert the script file a line at a time instead of sucking the
whole thing in first.  Would the append method from Mac::Memory achieve the
same thing (without tracking the amount inserted)?  OK, I can test the
second easily enough, but I figured I'm asking one question I might as well
ask two.

Thanks - Kevin


>At 09.44 -0400 1998.08.01, Kevin van Haaren wrote:
>>Thanks - I'll give it a whirl.  Hopefully the pieces are explained in your
>>(and Vicki's) book, most of my perl experience is on unix.  Off hand, do
>>you think it is possible to do a line at a time to conserve script memory,
>>or do I have to read it all in first?
>
>It should not be a problem to read the whole script in; the script probably
>won't be nearly big enough to hurt your memory usage.  Even if the script
>were a full MB, you could simply increase your MacPerl partition a bit.  I
>have mine set at 8 MB, and I would never have any problem with reading in
>any of my scripts to do something like this.
>
>That said, I don't know how easy it is to write to a resource in pieces
>anyway.  It should be doable, since writing is done in byte positions
>anyway (with the set() method from Mac::Memory), but I would rather do:
>
>  $resource_id->set(0, 1, $text);
>
>than:
>
>  my $pos = 0;
>  while(defined($text = <FILE>)) {
>    $resource_id->set(0, length($text), $text);
>    $pos += length($text);
>  }
>
>or whatever.
>
>My setCGImins droplet (on the CD) might be able to help you out some.  All
>it does is change a resource in a CGI.
>
>--
>Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
>%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])




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