"Peter Kappus" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]
...
> Thanks to all who have responded to my rather vague request.  Indeed, I
> should clarify a bit what I'm looking for.
>
> Because I'm extremely lazy, I'd like to use certain formatting shortcuts
in
> my HTML.  In a given document, I might have 15 different spacer gifs of
> different sizes to aid in precise formatting that would look something
like
> this:
>
> <img src="spacer.gif" height="50" width="10"/>

no offense, but when I see blank gifs, I see anti-lazy...

>
> In PHP, or ASP, for example, I would write a "spacer(height,width)"
function
> and call it in my block of HTML like so:
>
> <?spacer(50,10)?>
>
> which would create and send the image tag for me.
> I'd like, in perl, to do the following:
>
> print<<eob;
> <table border="0">
> <TR>
> <TD><?spacer(10,50)?></TD>
> </TR>
> </TABLE>
> eob
>
> Ideally, I would overload the print function so that it would search for
> statements between <??> delimeters and execute them.
> Of course, I could also say:
>
> my $spacer1=spacer(10,50);
> my $spacer2=spacer(50,100);
>
> print<<eof;
> <table>
> <TR>
> <TD>$spacer1</TD>
> <TD>some stuff</TD>
> <TD>$spacer2</TD>
> </TR>
> </TABLE>
> eof
>
> but it seems like there should be an easier way with fewer keystrokes and
> fewer intermediate variables.
>

Well, you can save yourself a bundle of keystrokes and use a templating
system and cascading stylesheets, but heres a quick fix:

[wadet@ecg-redhat wadet]$ perl
sub box {
  return('<img src="p.gif" height="'.$_[0].'" width="'.$_[1].'">');
}
print <<eot;
<table>
  <tr>
    <td>${\box(5,10)}</td>
    <td>${\box(7,10)}</td>
  </tr>
</table>
eot
Ctrl-D
<table>
  <tr>
    <td><img src="p.gif" height="5" width="10"></td>
    <td><img src="p.gif" height="7" width="10"></td>
  </tr>
</table>

see:

[wadet@ecg-redhat wadet]$ perldoc perlref

>
> Perhaps, my dream is completely quixotic, but so far, it seems like the
kind
> of thing that must be very easy if only I knew the right trick...

You need to understand references and the underlying semantics of computer
data structures. Set theory dosent hurt either. Then you dont even have to
think about it. Like breathing.

Also the
> only real benefit I've seen of PHP over perl-cgi is the ease with which
one
> can mix HTML and code (Naturally, most web architects will jump at the
> opportunity to tell you why this is a very bad idea but it often makes
life
> easier for small projects)

Ive never had a project stay small for long.

>
> I hope this clarifies things a bit.  If not..I guess I'll just need to do
a
> few extra keystrokes :)
>
> Many thanks!

no prob,

Todd W.



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

Reply via email to