Know when and when not to write networking code.

Even though Perl has support for low-level socket programming, that doesn’t mean that you have to program at the low-level. For common protocols such as FTP, HTTP, POP3, or SMTP, you can use modules that come with Perl to handle the transport details. libnet, the distribution that comprises the basic protocols, comes with Perl since 5.8. Many other protocols, such as SSH, have implementations on CPAN. You can also install from CPAN many higher level libraries, such as LWP and WWW::Mechanize. Continue reading “Know when and when not to write networking code.”

Use Carp::REPL as an interactive Perl shell.

Wouldn’t it be great if you could stop your program right before it died so you could see what’s causing the problem? You could start the Perl debugger and step your way to the problem, or set up some break points, but that’s often too much work. The Carp::REPL module let’s you drop into a debugger just at the point you need. Continue reading “Use Carp::REPL as an interactive Perl shell.”

Use scalar references to pass large data without copying.

References aren’t just for data structures, and many people overlook the benefit of references to simple scalars. With references to arrays and hashes you can keep those data structures in tact when you pass them to or return them from subroutines (Item 46: Pass references instead of copies). You don’t need to worry about scalar values because they are a single item in both the non-reference and reference form. Continue reading “Use scalar references to pass large data without copying.”

A Chinese translation of Effective Perl Programming is in the works

There’s a Chinese translation of _Effective Perl Programming_ in the works. I don’t know when it will be available: the translation will take some time, then the publisher has to put it on paper, then it has to show up in stores. I don’t have any details on where or how you can buy the translation. If you know those, please let us know and we’ll post the details here (even using your referral link).

However, if you’re reading this directly, the Chinese edition might not matter to you. :)

If you know about any other translations, tell us about those too. Often the author doesn’t find out about them until they get a copy, if they ever get a copy.

Perl 5.12 new features

Perl 5.12.1 is out, which is the sign that it’s time for normal users to pay attention to it: that first point release should have sanded down all the rough edges. As usual, the complete list of major changes is in the perldelta5.12.0 documentation, we’ll cover some more of the interesting features in The Effective Perler in the coming weeks. Our initial list of user-interesting features include: Continue reading “Perl 5.12 new features”

Compare dates as strings when you can.

Just because you find a module that does something doesn’t mean that you have to use it. There are many excellent date and time modules on CPAN, including most people’s favorite, DateTime. In your heady rush for program purity and elegance, don’t think that you always have to use objects to do your work. Sometimes the overhead of objects, which have to call (perhaps many) subroutines to do their work, is too expensive. Continue reading “Compare dates as strings when you can.”