Tag archives for: perl

Error Handling in Perl

Okay, this won't be the most exciting entry in the world. There are several different ways of logging or recording errors and warnings in perl, and I find I easily get confused. So this entry will serve as a very, very basic reference for me. Other people may find it useful. Or not.

Core Perl

die LIST

Taken from the Perl 5.10.0 documentation:

Outside an eval, prints the value of LIST to STDERR and exits with the current value of $! (errno). If $! is 0 , exits with the value of ($?>> 8) (backtick command status). If ($?>> 8) is 0, exits with 255. Inside an eval(), the error message is stuffed into $@ and the eval is terminated with the undefined value. This makes die the way to raise an exception.

Read more

New Blog

So I got myself a new weblog, hosted on Netfirms. I'm not particularly enjoying the Netfirms experience, but it was only $10 for a year and I get SSH access. They're quite skimpy with the perl modules, forcing me to install a bunch of stuff in my home directory.

I'm using a homemade blogging program because I got tired of blosxom's ugliness and I didn't really like what I saw of Bryar. I'm calling it YAWT in my head - short for Yet Another Weblog Tool. I'm hoping to extend it at some point to handle photo galleries in a seamless and efficient manner - my last attempt to write an online photo manager was quite slow. We'll see.

Read more

Scoping in Perl

I just read a very clear tutorial on Perl scoping mechanisms:

http://perl.plover.com/FAQs/Namespaces.html

I often get bitten by scoping issues but unfortunately (or fortunately?) it's usually easier in Perl to work around your problem than to understand the reasons behind it.

One part I found interesting was the section labelled "The Current Package" which explains the use of the package command in Perl. There is a tendency (or, at least, I have a tendency) to conflate the use of the Perl package command and, say, the use of the Java package declaration because they are often used to achieve the same effect, namely the separation of namespaces, and also because, by convention, they are used in a syntactically similar way. Because of this, it is easy to forget that the package command in Perl is just that: a command. You can call it from anywhere, multiple time from the same file even, and the effect is simply to change the current package - which in itself doesn't have a huge effect on how you write your code, just the way to access your variables.

Read more