Errors from a string eval can be tricky to track down since perl
doesn’t tell you where the eval was. It treats each of the string evals as a separate, virtual file because it doesn’t remember where the string argument came from. Since perl
compiles that during the run phase (see Know the phases of a Perl program’s execution), the information the compiler dragged along for filenames and line numbers is so longer around. Continue reading “Set the line number and filename of string evals”
Category: miscellany
Override die with END or CORE::GLOBAL::die
Perl lets you override the effects of warn and die by redefining the signals that Perl sends when you call those functions. You probably don’t want to use the signal from die, though, since it might mean a couple of different things. Continue reading “Override die with END or CORE::GLOBAL::die”
Use Git::CPAN::Patch to make quick patches to CPAN distributions
The Git distributed version control system is very popular in with Perlers, and even if you aren’t using it for your own project, you should know how to do simple things with it so you can interact with the most active parts of the community. It’s not that hard. Not only that, many Perl projects are on Github, and it’s something else you’ll know when you go to your next interview. Continue reading “Use Git::CPAN::Patch to make quick patches to CPAN distributions”
Choose the right Perl version for you
When you’re paying attention to the Perl news about new Perl releases, you need to know which ones matter to you. It seems like a simple question, but there are many things to consider. Do you use an experimental or stable release? In a stable release, which of the supported versions should you use? What does your vendor provide? What does your manager let you use? Continue reading “Choose the right Perl version for you”
Choose the right Perl distribution for you
There are several Perl distributions that you might choose, and each of them exists to serve a different audience. No one distribution is the right answer for you, and I can’t tell you which one to use without knowing about your situation and what’s important to you. Your possible solutions range from compiling, installing, and maintaining everything yourself to paying a support company to provide you with a compiled perl
and pre-compiled modules for easy installation. Continue reading “Choose the right Perl distribution for you”
Build a new perl in parallel for fast results
When you get a new perl
, you want to use it right away. Why wait for all that pesky compiling? As soon as the new tarball hits CPAN, you want to download it and start playing with it. You can make that process a little faster by running a parallel make
. Continue reading “Build a new perl in parallel for fast results”
Create random strings
This Item isn’t really about random hex digits, but we thought we’d expand on an Item in the original Effective Perl blog that Joseph set up to support the first edition of Effective Perl Programming. He had an Item titled “Creating a String of Random Hex Digits”. We won’t reproduce it here, so you should read his version too. Continue reading “Create random strings”
Use CORE when you need the real thing
Perl’s a dynamic language, which means you get to change the definition of almost anything while the programming is running. You can even change the defintions of Perl’s built-in subroutine. Once you (or the evil doer who wrote the module you need) change the definition, you might want to get back to the original, and Perl provides a way for you to do that. Continue reading “Use CORE when you need the real thing”
Compile a development version of perl
Nowadays, perl
development happens at a fast clip. Every month there’s a new development release that gives you a preview of what’s going to show up in the next stable version. This not only gives the perl
developers a chance to test the new perl in the wild, but also for you to try new features so you can get your application in shape for the next stable release of perl
. As The Effective Perl gives you a preview of some of the upcoming features, you’ll need a development version of perl
to try them for yourself. Continue reading “Compile a development version of perl”
Use the return value from srand
[This is another bonus, mid-week item since it’s so short and probably mostly useless as a tweak to what you already do.]
Perl 5.14 changes srand to return the seed that it used to start the pseudorandom number generator that gives you numbers through rand. There are plenty of interwebs that will explain the difference between real randomness and the sort that you get from computers, but for this item, suffice it to say that the numbers you get from perl are completely deterministic. If you start with the same seed, you get the same sequence. Continue reading “Use the return value from srand”