This days I had an idea, another since this is my work, have ideas to make the development of our systems faster and with less developers and experts. Don't say to use this or that, or that I'm wasting my time, they pay me very well to do that, ok?!

Well, here we have a envirionment that embeds Perl into HTML, yes another of this kind. It's similar to PHP, but the code is Perl, and have a lot of resources to work with OO entities, portable DB, etc... Well, it have all that we need to make portals fast.

Now I'm working to extend the Perl syntax, so, I made some simple analysis, and saw that the more common commands are:

print "<b>some quoted HTML<b>" ; ## and my $html = "<i>assign some html</i>" ;
But we know that when we declare a HTML with quotes is just sux! For example, when we want to declare with multiple lines, or to declare quotes and variables inside the quoted string:
print qq` <font color="#000000"> multiple lines and quotes </font> ` ;
Well, the syntax above is still simple, but remember that this is something that we write all the time! So, a long time ago we have added HTML blocks to the template system:
<html> <% print <% html_foo>(@args) ; %> <% html_foo(@args) <font color="#000000"> Args: @args </font> %> </html>
But I still see some developers declaring a lot of qq``! Why that? Because they don't want to create a new HTML BLOCK in the template just to print simple things. They think that HTML BLOCKS are very useful, but for blocks that will be used and called in many places.

So, I had some idea in the last week. Why not use some delimiter to declare a full line as a quoted string for output or assigment, making something similar to Perl comments:

>> this is an output! ## similar to: print "this is an output!\n" ;
And the advantage is that is not needed to open and close quotes, or to care about the use of quotes inside it, what is perfect for HTML data:
<table border="0"> <% for ( @names ) { >> <tr> >> <td color="#333333">$_</td> >> </tr> } %> </table>
Than I have added the same idea for assigment:
<% for ( @names ) { $html .= << <tr> . << <td color="#333333">$_</td> . << </tr> } %>
Well, what I really want is to know what you think about this extensions. I already have implemented basically the new syntax into our template system, just to see it working. I also think that this syntax can be helpfull to make a code cleanner, what will make us to win time on maintenance of this codes.

Thanks in advance!

Graciliano M. P.
"Creativity is the expression of the liberty".


In reply to Extending the Perl Syntax on PERL + HTML envirionments. by gmpassos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.