Slashdot Mirror


Perl 6 Grammars and Regular Expressions

An anonymous reader writes "Perl 6 is finally coming within reach. This article gives you a tour of the grammars and regular expressions of the Perl 6 language, comparing them with the currently available Parse::RecDescent module for Perl 5. Find out what will be new with Perl 6 regular expressions and how to make use of the new, powerful incarnation of the Perl scripting language."

10 of 202 comments (clear)

  1. Perl goodness by Zorilla · · Score: 5, Funny

    HXGF*&#$()#P*&ULJKDFHV)(&*#$utrhk:jlhdsf(p*&#$OJDF >KLJDFP)(*$#&pyu:

    Crap, I think I just accidentally programmed a web browser in Perl

    --

    It would be cool if it didn't suck.
    1. Re:Perl goodness by b12arr0 · · Score: 5, Funny

      Uh, that's not a web browser, it's clearly a web server.

    2. Re:Perl goodness by Anonymous Coward · · Score: 5, Interesting
      A web browser? That's:
      perl -MHTML::Strip -MIO::All -e 'print HTML::Strip->new->parse(io($ARGV[0])->scalar )'
      A web server? That's:
      perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })'
  2. hrm... by Anonymous Coward · · Score: 5, Funny

    "...zztop-wants-a-perl-necklace dept."

    i do not think that means what you think it means.

  3. Re:Big problem by Speare · · Score: 5, Informative
    Um, ALL PERL CODE IS TREATED AS PERL5 CODE unless you use a specific Perl 6 keyword in your script. Perl 6 interpreters will not require you modify your scripts AT ALL to use Perl 5 scripts.

    Therefore, it's just Perl 6 scripts which want to use Perl 5 regular expression syntax, which would want to use the :p5 modifier.

    Don't get your knickers in a bunch.

    --
    [ .sig file not found ]
  4. aw hell by The+Unabageler · · Score: 5, Funny

    I'm going to have to rewrite my sig.

    --
    perl -e '$_="\007/4`\cp%2,".chr(127);s/./"\"\\c$&\""/gees; print'
  5. Re:Why would a satisfied Perl5 user migrate? by WWWWolf · · Score: 5, Interesting

    Yeah, Perl 5 hasn't changed that much over time. But it has been around for a while. Perl 6 is just different.

    From what I have seen from the announcements, the Perl 6 syntax looks far cleaner, probably more consistent and less ugly. Some of the new tricks look genuinely handy. For example, if it seems like type checking would be a good idea, you can have it if you want it, even on compile time!

    Especially the regular expressions side seems pretty interesting, as noted in this article. Regular expressions have always been a poor but effective replacement for grammar-based parsing, and now finally Perl is going to have both integrated. There's probably going to be less whining about line noise.

    And then there's something that I find especially interesting, though it hasn't been explained in detail yet: Complete tuning of the object system. In case you haven't noticed, Perl 5's object system is a complete and utter mess that looks and smells like it has been added as an afterthought, and rest assured it's going to be changed radically for better in Perl 6. I'm definitely waiting eagerly to see what Perl 6's take is going to look like - I sure hope it's something like Ruby, only it smells like a camel =)

  6. Re:Grammar by Mr.+Muskrat · · Score: 5, Informative

    Perl never was an acronym. It's a backronym.

    Perl is the language and perl is the interpreter. Remember, "only perl can parse Perl" and it's easy to remember.

  7. Re:Big problem by Zaak · · Score: 5, Informative
    Meaning that it is not backward compatible without modifying your source code.

    Thus spake Larry Wall in Apocalypse 5:
    ...we took several large steps in Perl 5 to enhance regex capabilities. We took one large step forwards with the /x option, which allowed whitespace between regex tokens. But we also took several large steps sideways with the (?...) extension syntax. I call them steps sideways, but they were simultaneously steps forward in terms of functionality and steps backwards in terms of readability. At the time, I rationalized it all in the name of backward compatibility, and perhaps that approach was correct for that time and place. It's not correct now, since the Perl 6 approach is to break everything that needs breaking all at once.

    And unfortunately, there's a lot of regex culture that needs breaking.

    And from Apocalypse 1:
    It would be rather bad to suddenly give working code a brand new set of semantics. The answer, I believe, is that it has to be impossible by definition to accidentally feed Perl 5 code to Perl 6. That is, Perl 6 must assume it is being fed Perl 5 code until it knows otherwise.

    In other words, it is backwards compatible, it isn't backwards compatible, and when you install Perl 6, you are installing both.

    TTFN
  8. Let me guess.... the usual Perl backlash by Anonymous Coward · · Score: 5, Interesting
    I get sick of the 'standard' backlash every time a Perl article is posted. Why do people have such a problem with Perl? It's an excellent, high-level general purpose programming language with a huge range of extension modules available. I have personally used Perl for many projects, as do TicketMaster, ValueClick, Morgan Stanley and Ryanair and I've also learnt a lot about software engineering and computing through Perl.

    Yes, it does include a lot of symbols, but there is payback to learning them, and really most programs won't use much beyond $ % # () [] {}. Unlike some languages, Perl is not what I would describe as a 'bondage' language. If you want to program sloppy, you can program sloppy. That's fine by Perl. And this generousity is what gives Perl its bad reputation. This is funny since I and most knowledgeable Perl programmers can write perfectly clear and maintainable code. The way we do this is no secret--it's just by commenting appropriately, using meaningful identifier names and following the Perl style guidelines.

    People can mock Perl all they like, but it is still a widely used powerful programming language and I am more productive in it than any other language. As a parting comment, a Cisco employee once told me (off the record of course!) that "Cisco would fall apart without Perl".