Day 194..204: (blank)

autrijus on 2005-08-19T18:03:42

Took a whole day to get all data successfully salvaged to the new 80GB hard disk. Sorry, no journal today -- I'll try to make it up tomorrow.

Update: It is tomorrow now and I'm still neck deep in this $work deadline thing. Sorry.

Update: Another day passed; thanks to both Parsec and Catalyst I should be able to survive this. But I'm missing all the interesting p6-on-p5 and perl5 typecheck fun. :-(

Update: It's been a week; $work and moving has been throughly consuming. Maybe I'll catch up the rapid movements for p6-on-p5 this weekend, maybe not. Sigh.


embedded perl

Hurina on 2005-08-23T05:01:05

I think Perl 6 should support html embedding that php has to enable Perl to be embedded in html or xml. The only advantage PHP has over Perl is that it can be embedded within html. PHP is not a general purpose language. In addition multilanguage scripting can also be implemented by language code tag attributes. The project http://sexx.sourceforge.net/ also mirrored on cpan as a Perl script demonstrates this.

The Perl code can be put within code
markup tags "<code>" "</code>" similar to D. This would allow perl to compete
with PHP in webscripting by executing what is between the code tags and displaying the rest of the html. The code tag markup is superior to PHP and allows for language attributes and special rendering like Mason.

PHP focuses on putting the tags within an opaque
<? ?>. This is extremely
limiting and very indefinite namespace wise.
I think it would be really cool if Perl supported embedded Perl within html or xml tags for perl 6.

This is also similar to Digitalmars D where the code is put in a code tag.

This is an example for hello.php.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>

This would be the html embedded Perl script web.hpl. The hypertext markup version of perl can been written as hpl or hypertext perl.
<html>
<head>
<title>Perl Test</title>
</head>
<body>
<code> print "<p>Hello World</p>"; </code>
</body>
</html>

This would render as:
<html>
<head>
<title>Perl Test</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>

Currently, There are embedded versions of Perl in Mason and http://perl.apache.org/embperl/ embedded perl. But a code tag is much more flexible.

Re:embedded perl

nothingmuch on 2005-08-23T19:32:57

http://search.cpan.org/perldoc?Embperl or http://www2.ecos.de/embperl/

Re:embedded perl

mx.2000 on 2005-08-24T11:41:06

If I remeber correctly, you can embed code in Strings with {...}. (the Perl5-hack of this would be @{[...]} )

So you could just write:

  say $headerstuff;
  say "
  <html>
  <head>
  <title>Perl6 Test</title>
  </head>
  <body>
  { say '<p>Hello World</p>' }
  </body>
  </html>
  ";

or something like that. (Actually, it may work better without 'say' inside the string.)
 

Re:embedded perl

Hurina on 2005-08-26T02:24:15

Thats true you can write that in Perl. However,
It would still be interesting if there an option
in Perl 5 or 6 to parse html and process the code
inside a tag and display the html and run the code. This would be an integrated perl option not provided as a separate module.

This is like a Perl version of PHP and would render PHP obsolete.

Perl 6 could do it this way.
ie.
% more perl6.html
  <html>
    <head>
    <title>Perl6 Test</title>
    </head>
    <body>
    <code>
    say '<p>Hello World</p>';
    </code>
    </body>
    </html>

% pugs -html perl6.html
<html>
    <head>
    <title>Perl6 Test</title>
    </head>
    <body>
    <p>Hello World</p>
    </body>
</html>

Re:embedded perl

Hurina on 2005-08-26T02:32:17

The PHP group recently had a discussion and conspired to do in Perl. No, I'm just kidding
but there are those who would meet in a dark room and conspire to dethrone a king or remove a wall.

As a further extension

% more perl.program.html
<html>
<p>This is the way to barbosa</p>
<code>
sub combinations returns Array (@list is rw) {
    return () unless @list.elems;
    my @ans;
    for 1 .. 2**@list.elems-1-> $num {
            push @ans, [ @list[ (0 .. sqrt($num)).grep:{ $num +& (2**$_) } ] ];
    }
    return @ans;
}
</code>
<p>Here is the answer to life the universe and everything. </p>
<code>
my @list = (1..4);
combinations(@list).perl.say;
</code>
</html>

Re:embedded perl

Hurina on 2005-08-26T02:33:13

As Perl 6 would say rumors of my death are greatly exagerated.....

PerlHP

pos on 2005-08-27T17:04:50

It already exists: http://wakaba.c3.cx/perlhp/