Thursday, February 28th, 2008
Category: Perl, jQuery
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.
PERL:
-
-
use pQuery;
-
-
pQuery("http://google.com/search?q=pquery")
-
->find("h2.r")
-
->each(sub {
-
-
print ($i +
1),
") ", pQuery
($_)->
text,
"\n";
-
});
-
It is always interesting to see ideas ported from Web JavaScript to other languages.
Tuesday, October 16th, 2007
Category: JavaScript, Library, Perl
Viktor Kojouharov was sick of constantly having html code snippets inside his perl code. He was seeing too many projects where the code was a messy mixture of perl, html, and in some places, javascript. Since he is familiar with the Gtk+ toolkit he decided to make something similar targeted for the Web.
He ended up with IWL which is, in Viktors words:
basically a graphical toolkit, or widget library, much like Gtk+ or the ETK library for enlightenment. The main goal of this library is to create a full blown RIA, without the need to write html in your code. When I started working on it roughly a year and a half ago, there was nothing similar existed for Perl. By using the library where I work, it has so far mostly achieved its main objective (and has also proven to be an excellent subject for my diploma thesis :))
If you are a Perl developer who prefers writing apps in a toolkit style like below, then IWL may be fore you:
PERL:
-
-
use IWL;
-
-
# create the main container, and a few widgets
-
my $page = IWL::Page->new;
-
my $frame = IWL::Frame->new;
-
my $iconbox = IWL::Iconbox->new
-
(width => '800px', height => '600px');
-
my $button = IWL::Button->newFromStock
-
('IWL_STOCK_CANCEL');
-
my %some_icon_info = ("foo.jpg" => 'foo', "bar.png" => 'bar');
-
-
# Setting up the icons and adding them to the iconbox
-
foreach (keys %some_icon_info) {
-
my $icon = IWL::Iconbox::Icon->new;
-
$icon->setImage($_);
-
$icon->setText($some_icon_info{$_});
-
$icon->setDimensions('64px', '64px');
-
$icon->setSelected(1) if $_ == 'something';
-
$iconbox->appendIcon($icon);
-
}
-
-
$page->appendMetaEquiv("Cache-control" => "no-cache");
-
$frame->setLabel("Frame label");
-
# Adding the children to their parents
-
$frame->appendChild($iconbox);
-
$frame->appendChild($button);
-
$page->appendChild($frame);
-
-
# Finally printing the page
-
$page->print;
-
Tuesday, March 21st, 2006
Category: Ajax, Games, Perl
In this post on the Ajax Magazine blog, there's mention of WEBoggle, an Ajax-enabled web-based multiplayer game of Boggle.
WEBoggle is a web-based Multiplayer Boggle Game where you can play and have fun, but the website was already down this morning the second time I check it to write about it. The game is too much fun, and personaly I find it very addictive too.
When the timer starts, each player searches the assortment of letters for words of three letters or more (four or more on the 5x5 board). When you find a word, type it into the blank and press the ENTER key. Words are formed from adjoining letters. Letters must join in the proper sequence to spell a word. They may join horizontally, vertically, or diagonally, to the left, right, or up-and-down. No letter cube, however, may be used more than once within a single word.
The game is contsntly running, so anyone can connect at any time (no need to wait for other players) and there's a running total on the sidebar of everyone else's words for the previous round. There are also other boxes near the bottom of the screen with the "words only you found", "words you missed", and "words everyone missed" from the last round. The layout of the page is simple, and two types of games are offered - a 4 by 4 grid and a 5 x 5 grid. The backend is written with a combination of Perl and Ajax.
Friday, March 3rd, 2006
Category: Ajax, Perl
From the O'Reilly Perl.com site, there's a new article talking about a simple, quick way to enable Ajax usage inside of Perl, with the help of a module from CPAN.
If you're even remotely connected to web development, you can't have failed to have heard of Ajax at some point in the last year. It probably sounded like the latest buzzword and was one of those things you stuck on the "must read up on later" pile. While it's definitely a buzzword, it's also quite a useful one.
In short, it's about making your web pages more interactive. At the core, Ajax techniques let you update parts of your web page without reloading the whole page from scratch. This enables some very cool effects.
When you log in to Flickr, you can see the photos that you have just uploaded. Behind the scenes, Flickr uses JavaScript to make a separate call back to the server to update the details. It does so by using something called XMLHttpRequest. You'll hear a lot about this as you explore Ajax.
They continue on, explaining a bit more about what Ajax is and how it's used before getting into the actual usage of it. They show you how to grab the Perl module, CGI::Ajax, from CPAN and help you create a sample introductory application - a username checker. They wrap it up with a look at how Ajax is used in the "real world", and note that there are times to use it and times to push it aside, depending on the app.
Wednesday, February 15th, 2006
Category: JavaScript, Library, PHP, Perl, Toolkit
Ajax Agent is another Ajax toolkit/library/framework created by some old Ajax pro's (the Lead Architect behind Onepage Portal Server (now Sybase Enterprise Portal) & one of the core engineers behind the Content Express For Microsoft Commerce Server).
Their aim is to make Ajax work as simple as possible.
The PHP version offers three steps to get started with the framework:
PHP:
-
-
include_once('agent.php');
-
$agent->init();
-
agent.call('url','server_function', 'client_handle', param1, param2, ...);
-
The first line is declared to include the AJAX Agent library, initialize the agent framework & instantiate the server side 'Agent'. The second line instantiates the client side 'Agent'. The third line which runs on the client side within the javascript browser environment, uses the client side 'Agent' to directly call the server function asynchronously. AJAX Agent supports complex data types like associated arrays & objects. It makes use of JSON (JavaScript Object Notation) for data interchange format to achieve this.

Saturday, November 5th, 2005
Category: Perl, Toolkit

Encodable Industries has released a nice, simple Ajax upload component with a live progress bar. Its a single perl script that can be dropped into any web server with CGI support.
Features include max upload size, security via password protection, the real time progress bar, and display of time remaining and elapsed. You can view the source to take a look at the well commented preferences at the top to tweak things how you like. Or try it out with the live demo.
(seen at digg.com)
Thursday, September 1st, 2005
Category: Perl, Screencast
Catalyst is a framework that is trying to do for Perl, what Rails has done for Ruby.
You can view screencast movies, including one which walks you through creating an auto complete piece of Ajax

Tuesday, July 26th, 2005
Category: Editorial, Perl
One of the great gems of Perl is CPAN. Rael noticed that some Perl hackers are jumping into some JavaScript code, and built JSAN, a place to find comprehensive information on JavaScript libraries.
As Rael says...
The most interesting find in the archive thus far has to be JSAN library itself, allowing scripters to import rather than <script src="... other libraries:
// Or in a library.
try {
JSAN.use('Some.Library');
} catch (e) {
alert("Requires JSAN");
}
Very cool.