Thursday, February 28th, 2008

pQuery where p = Perl

Category: jQuery, Perl

We have talked about a pQuery before, which was a PHP port of jQuery. Now we have a new pQuery for the Perl community:

pQuery is a pragmatic attempt to port the jQuery JavaScript framework to Perl. It is pragmatic in the sense that it switches certain JavaScript idioms for Perl ones, in order to make the use of it concise. A primary goal of jQuery is to “Find things and do things, concisely”. pQuery has the same goal.

pQuery exports a single function called pQuery. This function acts a constructor and does different things depending on the arguments you give it.

A pQuery object acts like an array reference (because, in fact, it is). Typically it is an array of HTML::DOM elements, but it can be an array of anything.

Like jQuery, pQuery methods return a pQuery object; either the original object or a new derived object. All pQuery METHODS are described below.

  1. use pQuery;
  3. pQuery("")
  4.  ->find("h2.r")
  5.  ->each(sub {
  6.    my $i = shift;
  7.    print ($i + 1), ") ", pQuery($_)->text, "\n";
  8.  });

It is always interesting to see ideas ported from Web JavaScript to other languages.

Posted by Dion Almaer at 10:28 am

3.2 rating from 62 votes


Comments feed TrackBack URI

What ever happen to pQuery for PHP. I when to the website recently and its down. Server-side helpers are okay if you need something quick and dirty but they cannot do everything. Its still great to have the option available and I’m glad there are more options coming out for designers that use jQuery. Most frameworks seem to favor Prototype and Script.a.licous, nothing against them, just I real like programming with jQuery.

Comment by mydesignbuddy — February 29, 2008

It is not similar to Perl, except “my” and “use” operators. What is it?

Comment by John123 — March 24, 2008

Little correction to the article, mentioned pQuery aka PQuery wasn’t a port of jQuery to PHP. “PQuery is to jQuery as Rails helpers is to Prototype and”. PHP port o jQuery which you wrote about is phpQuery and here’s the link:

Comment by TobiaszCudnik — October 21, 2008

Leave a comment

You must be logged in to post a comment.