blog.scriptdigital.com [Archives]

Emmanuel M Décarie's weblog on scripting.
Mostly PHP, Radio UserLand, Perl, Applescript and OS X.
RSS/XML Feed | scriptdigital.com | Picture | Search
Categories: AppleScript | BBEdit | Internet | Javascript | OS X | Perl | PHP | Python | Review | Radio UserLand
Technorati URL search for http://blog.scriptdigital.com.
Search Technorati for information relating to the URL or keyword of your choice.
... Original post: blog.scriptdigital.com: Emmanuel M Décarie's weblog on scripting. by at Daypop Search - filter replacement ...
Filter Replacement View Technorati URL search

Perl

Sun 11 May 2003

Fun with NetNewsWire, RSS, Perl and Apache logs

I made a little cgi script in Perl to display part of my Apache log in NetNewsWire. Here's a picture. The title in the headline shows the IP of the client, and the category shows the file requested. The time the request was made, the user-agent and the referer are displayed in the body of the post.

It was for me a sort of proof of concept. Here's a link that will give you some background on my line of thinking.
http://groups.yahoo.com/group/syndication/message/3791

NetNewsWire is good for displaying tabular data. But unfortunately, for now, NetNewsWire can't display much in the headlines. Since I'm not so familiar on how to extend RSS 2.0 and RSS 1.0, I'm not sure if its a limit of the newsreader or the various RSS specs.

Anyway, think of the headlines pane of NetNewsWire as a spreadsheet, and you'll understand how cool it could be to use RSS to encode tabular data, and how nice it could be to display it in NetNewsWire, or any newsreader that display categories, and offer to order these categories with a simple click on the header on the column. This make my mind spinning.

I used RSS 2.0 for my example because its easy to make.

The Perl script is here.
http://blog.scriptdigital.com/gems/httpdlog2rss.txt

You need the Perl module Parse::AccessLogEntry to use the script.

Once the script is installed as a cgi, just register its url in NetNewWire. It take some time for NetNewsWire to parse the feed, and depending of the size of your log, it could take more time. Also, there is nothing optimal in this little hack, so use it at your own risk.

comments: 0

6:23PM EDT [ /Perl | # ]

Tue 11 Feb 2003

PerlPad 0.1

I didn't have time yet to play with PerlPad, but it look promising. Its based on the CamelBones framework. Here's what Thilo Planz, the author, have send to the Perl Mac OS X list to announce this new release:

Hi all,

I have been playing around with Camelbones a little and placed my results on SourceForge:

http://perl-pad.sourceforge.net/

It is a small Cocoa application that lets you run Perl from other apps using System Services.

You can a) evaluate Perl code from any TextInput b) process the current selection with some Perl code (nice to test some regex) c) process the system pasteboard in the same way

You can also define buttons for your favorite Perl snippets and even create add-on services for the service menu. The Perl environment provided is persistent (as long as the app stays alive), allowing you to share data between invocations and load custom Perl modules.
http://archive.develooper.com/macosx%40perl.org/msg04876.html

I would like some feedback, basically to see if the thing installs on other computers than my own and if someone finds it useful.

Since it is my first attempt at Cocoa and Interface Builder still confuses me a lot, I am not sure if the code itself can serve as example. It does feature Services, access to the pasteboard, half of an NSBrowser and a dock menu.

Requirements:

You can follow the thread on the Perl Mac OS X list here.

comments: 0

9:03AM EST [ /Perl | # ]

Fri 07 Feb 2003

Learn Perl Online Library

Hey, that's sweet! learn.perl.org is offering the Learn Perl Online Library. [via: Perl.com Newsletter]

Beginning Perl
by Simon Cozens, Peter Wainwright.
700 pages. Wrox Press Inc. (May 25, 2000).

Embedding Perl in HTML with Mason
by Dave Rolsky, Ken Williams. 318 pages.
O'Reilly & Associates. (October 2002).

There is also sample chapters from:

Writing Apache Modules with Perl and C: The Apache API and mod_perl
by Lincoln Stein, Doug MacEachern, Linda Mui (Editor).
724 pages. O'Reilly & Associates.(March 1999).

mod_perl Developer's Cookbook
by Geoffrey Young, Paul Lindner, Randy Kobes. 650 pages.
Sams Publishing. (January 2002)

Also you can contribute to learn.perl.org.

We are looking for HOW-TOs ,tips (less than 500 words) and articles (1000-1500 words). A few examples of material we are interested in,

Five things I do every day with DBI

A Case Study for Optimizing a Regexp

anything on mod_perl (see also www.take23.org )

The 5 Minute Quick Start Guide to XML-RPC in Perl (take them from knowing nothing to writing clients and servers in a very small space)

http://learn.perl.org/contribute/

You can also subscribe to a Perl mailingtips: http://learn.perl.org/tips/

I just perused the tips and found a nice one for installing Perl modules.

Perl Tip 6: Install modules from CPAN

comments: 0

12:45AM EST [ /Perl | # ]

Tue 04 Feb 2003

Mark Jason Dominus on the 'strict' Perl pragma

Mark Jason Dominus have set in October 2002 the perl-qotw list where he post Perl quizzes. Its a fun way to learn Perl.
http://perl.plover.com/qotw/

He posted in November 2002 a rant (see point #9 at the end of the post) on how some Perl programmers are obsessed with "usewarningsandstrict", and more generally, on how some programmers are carried away by their dogmatism. Here's an excerpt.

I believe that one of the biggest problems with programming as a profession is that programmers are fearful and superstitious. Programming is only about sixty years old. When chemistry was sixty years old, practitioners were trying to turn lead into gold, to extract the essence of fire, and so forth. After a few hundred years they learned a little more and began to study phlogiston. So we are in the dark ages of programming, and we live in a dangerous world that we do understand only poorly. Many people respond to this with superstition: "Always use objects." "Never use a global variable." "Perl is better than Python." "Always use strict."

(...)
I think almost anyone who says "always use strict" is suffering from this lack of understanding. "strict" is not one but three features, and none of these three features has anything at all to do with the other two. Saying "always use strict" is like saying "always use a hammer, a screwdriver, and a drill." For some projects, perhaps only the hammer and drill are appropriate, and the screwdriver is an irrelevant distraction. So it is too with "strict". People are being encouraged to load up with tools that they don't know how to use.

Subject: Solutions and Discussion for Perl Quiz of the Week #5
Date: Tue, 19 Nov 2002 17:49:52 -0500
http://perl.plover.com/~alias/list.cgi?mss:30

This is a good read for anyone wanting to understand when its appropriate to use or not use the 'strict' Perl pragma.

comments: 0

10:03AM EST [ /Perl | # ]