Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Will my code work in Perl 6?

by $code or die (Deacon)
on Feb 06, 2002 at 17:43 UTC ( [id://143651]=perlmeditation: print w/replies, xml ) Need Help??

Yes (sort of). But are you really asking that question now?

If you want to know about Perl5-isms that will not be supported in Perl 6, I'll point you to this document I've been putting together. I'm currently looking for work, but that's boring, so I spent a day last week re-reading the Apocalypses and Exegeses. If like me, you're interested in Perl 6 and the new language features, you probably wonder what things you'll need to change when you get your hands on that first alpha release (apart from the obvious dot and underscore).

So far, there's not very much that has been removed from the language. And in Apocalypse 1, Larry says he wants to keep it that way. However, it's early days, almost a year later, we're on Apocalypse 4 and Larry (perhaps jokingly) mentioned that there'll be an Apocalypse 26. So that's why I'm compiling this reference now, it'll be much more work to leave it until Perl 6 ships.

Please let me know if I've got something wrong, or overlooked something. I am sure that I'll have missed things on the perl6* mailing lists - I've only had time for the digests. I plan on keeping this list updated with each Apocalypse and Exegesis.

Here's that URL again:

Update: Fixed the link - sorry, should have tested it. Thanks also to robsv for correcting my HEREDOC.

___ Simon Flack ($code or die)
$,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
=~y'_"' ';eval"die";print $_,lc substr$@,0,3;

Replies are listed 'Best First'.
Re: Will my code work in Perl 6?
by Juerd (Abbot) on Feb 08, 2002 at 14:33 UTC

    Perl 5
    while <STDIN> { ...

    In Perl 5, the parens are not optional. And please use a monospaced font for code :).

    String Concatenation from . to _. Note: whitespace is neccessary.

    Only if there's a \w character next to it. $foo{bar}_$foo{bar} will be possible, but $foo_$bar will not (or at least not DWIM).

    'for' is now a shortcut for 'foreach'.

    I don't know if shortcut is the right word, but currently, for and foreach are exactly the same. That is, foreach (EXPR;EXPR;EXPR) and for (LIST) work.

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

      Hi, thanks for the corrections.

      And please use a monospaced font for code :)

      I thought I was! It looks ok on my screen. But my fonts were a little messed up by Opera. I checked it a few days ago in IE and it looked ok too.

      I was confused about the for/foreach bit. Apocalypse 4 says: 'And for will now always mean "foreach"'. Now I'm more confused. perlsyn says: '"foreach" keyword is actually a synonym for the "for" keyword'. I suppose it means that neither for, nor foreach will have the C-style (;;) construct.

      Thanks for the help.

      ___ Simon Flack ($code or die)
      $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
      =~y'_"' ';eval"die";print $_,lc substr$@,0,3;
        It seems Konqueror renders <pre> in whatever font the underlying element has. I don't know if that's how CSS was supposed to work, but you could of course add PRE { font-family: courier; } to your style sheet.

        2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://143651]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-05-26 05:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found