On Friday, Feb 14, 2003, at 19:02 US/Pacific, Peter Kappus wrote:
[..]
In PHP this can be streamlined by creating a function which prints out your
image tag for your and accepts the height and width as parameters. like so:

function spacer($y,$x){
?><img src="spacer.gif" height="<?=$y?>" width="<?=$x?>"><?
}
[..]
i'd like to be able to use the "print<<eof;" behavior to send large blocks
of HTML to the browser. Is there A way that I can reroute that statement to
send my string through a sub that basically does the following:

sub sendit{
my $txt = shift;
$txt =~ s/<\?(.+?)\?>/(?{eval($1)})/g; #evaluate what's between my
<??> delimeters and print the result
print $txt;
}
[..]

What I think you have stumbled into is the problem of wanting
on the one hand to pack php/javascript INTO the html that is to
be sent, while at the same time wanting to 'pre-process' the
text of the html page PRIOR to sending it that happens then to
want to 'evaluate' your php/javascript....

I'll confess to being mostly confused by what you have
and what you want. The idea of the "print<<eof;"  which
you lay out a solution for, and then reject, because of the
typing count....

So it's not clear which 'saving' you are really after.

I had a function

	sub set_image($$$)
	{
		my ($height, $width,$gif) = @_;
		$gif ||= 'spacer.gif';
		my $p = '<img src="' . $gif . '" heignt="' .
					$height . " width=" . $width . '">' ;
	}

which you would call with

	my $image = set_image(50, 128);

if you wanted to use the 'default' gif...
So that I could build up other things, one of which is
how I plonk them into a scalar called $page with gags like

	my $page = start_page($header, $meta, $jscripts);

	$page .= $foo . $image . $bar;

	$page .= do_end_of_page();

I of course 'collect' all of this into the scalar $page
which has all of the html - and then do something like

	make_header_and_send($page_type, \$page);

where that is defined as

#------------------------
#
sub make_header_and_send
{
	my ($type, $page_ref ) = @_;
	
	my $len = ($$page_ref) ? length($$page_ref): 0;
	
	my $head = simple_cgi_header($type, $len);
	
	if ( $len > 0 ) {
		print $head . $$page_ref  ;
	}else{
		print $head ;
	}

} # end of make_header_and_send

#------------------------
#
sub simple_cgi_header($$)
{
	my ($type, $len) = @_;
	
	my $header = "Content-Type: $type" . $CRLF .
				"Content-Length: $len" . $CRLF . $CRLF;

} # end of simple_cgi_header


As you will notice, I'm NOT trying to evaluate the '$page'
prior to sending.... Stuff that needs to get to the browser
so that it can solve 'browser side' reality, goes to the
browser, and we leave it to be happy there...

So you might want to resolve which 'saving' you are
trying to make in the process...


ciao
drieux

---


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to