background preloader

Perl

Facebook Twitter

Strawberry

The Book is Out! - Modern Perl Books, a Modern Perl Blog. After countless commits, the generosity of dozens of proofreaders, and far too long proofreading the index, Modern Perl: the book is available! You can buy a lovely print version from any well-stocked online vendor (and you're more than welcome to walk into your favorite neighborhood bookstore and request a special order given the book's ISBN: anyone who can order from Ingram can get the book in stock.)

The ISBN-10 is 0-9779201-5-1 and the ISBN-13 is 978-0-9779201-5-0. Either should work. If you prefer an electronic version, my publisher has agreed to make available both letter- and A4-sized versions of the book suitable for printing or browsing on your favorite device. We're also working on an ePub version. (Getting clickable intertextual links working in ePub was trickier than in PDF, so go figure—but isn't it nice to have clickable links in an index?) These are free of cost and free of DRM, but not free of obligation. Perl Cannot Be Parsed: A Formal Proof. [ UPDATE 27 Aug 2009: Readers interested in the topic of this node will want to look first (or instead) at the series of three articles I wrote for The Perl Review, now available online. They lay this proof out more carefully and with thorough explanations, in three different versions. ] [ At this point this post should be considered mainly of historical interest. One especial defect is that it frames the issue in terms of "static parsing", implying that there are no similar issues with "dynamic" parsing. ] In the man page for PPI, Adam Kennedy conjectures that perl is unparseable, and suggests how to prove it.

Below I carry out a rigorous version of the proof, which should put the matter beyond doubt. I've become interested in the question because I've just released an alpha version of a general parser (Parse::Marpa) on CPAN, which I think will allow static parsing of large portions of Perl 5, and I wanted to know what is achievable. Theorem: Parsing Perl 5 is Undecidable. Net::Twitter - Perl interface to twitter.com. Use Perl: All the Perl that's Practical to Extract and Report.

Parsing HTML with HTML::PARSER - The Perl Journal, Spring 2000. Ken MacFarlane Perl is often used to manipulate the HTML files constituting web pages. For instance, one common task is removing tags from an HTML file to extract the plain text. Many solutions for such tasks usually use regular expressions, which often end up complicated, unattractive, and incomplete (or wrong). The alternative, described here, is to use the HTML::Parser module available on the CPAN ( HTML::Parser works by scanning HTML input, and breaks it up into segments by how the text would be interpreted by a browser.

<A HREF="index.html">This is a link</A> would be broken up into three segments: a start tag (<A HREF="index.html">), text (This is a link), and an end tag (</A>). In this article, I'll first give a simple example on how to read and print out all the information found by HTML::Parser. As of this writing, there are two major versions of HTML::Parser available. Getting Started #! No output whatsoever. The Identity Parser 1 #! The HTML Tag Stripper.

Perl tricks by Neil Kandalgaonkar. Author: Neil KandalgaonkarFormatting: Laurent CAPRANI Look here for a nicer version of this page that Neil made. Contents Primality regex I found the actual one-liner Abigail originally used from How it works STATEMENT if COND Cool perl syntax, a statement may have 'modifiers' at the end like this. Shift shift normally removes the first element of an array and returns that element, like popping from the beginning. 1 x shift x is the repetition operator. The logical negation of =~, will succeed if the regex does NOT match.

The regular expression Example To see how it works let's consider the case of N = 9. So, you can see how this process is analogous to trying to divide a number by successively larger divisors, leaving no remainder. This vs. mine BTW: this also is much more efficient than the one I showed the group, with the addition of a single character! My regex always had to backtrack from the maximal match; since Abigail made the 11+? Consulting Perl Script: SC.pl.