Thursday, February 28th, 2008

pQuery where p = Perl

Category: jQuery, Perl

<p>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;
  2.  
  3. pQuery("http://google.com/search?q=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.

Related Content:

Posted by Dion Almaer at 10:28 am
3 Comments

+++--
3.2 rating from 61 votes

3 Comments »

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 Script.aculo.us”. PHP port o jQuery which you wrote about is phpQuery and here’s the link:
http://ajaxian.com/archives/plaintemplate-phpquery

Comment by TobiaszCudnik — October 21, 2008

Leave a comment

You must be logged in to post a comment.