O'Reilly Answers is a community site for sharing knowledge, asking questions, and providing answers that brings together our customers, authors, editors, conference speakers, and Foo (Friends of O'Reilly). More »
taken from perlfaq8
This is a difficult question to answer, and the best answer is only a guess. What do you really want to know? If you merely want to know if one of your filehandles is connected to...
Here's a benchmark with Perl 5.010. Note that 5.010 has a new /p flag that supplies a ${^MATCH} variable that acts like $& but for only one instance of the match or substitution oper...
There is a variety of software (including the Unix command-line
utility uniq and Windows PowerShell
cmdlet Get-Unique) that can help you remove duplicate lines in a file or
...
Perl understands numbers specified in binary (base-2), octal (base-8), and hexadecimal (base-16) notation only when they occur as literals in your programs. If they come in as data—such as by readin...
If you want to multiply a pair of two-dimensional arrays, use the PDL modules, available from CPAN. PDL is the Perl Data Language—modules that give fast access to compact matrix and mathematical fun...
If you want to make random numbers in a given range, inclusive, such as when you randomly pick an array index, simulate rolling a die in a game of chance, or generate a random password, use Perl's...
If you want to round a floating-point value to a certain number of decimal places, use the Perl function sprintf, or printf if you're just trying to produce output:
# round off to ...
If you want to convert between regular numbers and Roman numerals, use the Roman module from CPAN:
use Roman;
$roman = roman($arabic); # convert to roman numerals
...
If you have a string representing a headline, the title of book, or some other work that needs proper capitalization, use a variant of this tc( ) titlecasing function:
INIT {
our %nocap;...