Friday, September 10th, 2010
Perl Language Basics

Namespace pollution in scripts under Apache::Registry

With mod_cgi, since the script is initialized every time, the variable $required_name will always start out undefined. However, with mod_perl’s Apache::Registry, once $required_name is defined, it ...

More Perl Language Basics

Iterate over environment variables in Perl

foreach $key (keys %ENV) { print "Environment key $key is $ENV{$key}\n"; }

Setting Cookie Expiration Without Using the CGI Module

#!/usr/bin/perl -T use strict; my @monthnames = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my @weekdays = qw/Sunday Monday ...

$_ in perl

The "Dollar underscore" or $_ is the default argument to the perl operators and control structures.while ( defined( $_ = ...

Generate random numbers in perl

We can use perl's rand function to generate random numbers. This code generates and prints a random integer between 15 and ...

Perl Roman numerals and Arabic numerals

We can use the Roman module from CPAN. The Roman module provides both Roman and roman for converting Arabic ("normal") numbers ...

Perl decimal to binary

To convert a Perl integer to a text string of ones and zeros, first pack the integer into a number in ...

Perl binary to decimal

To convert a text string of ones and zeros to a Perl integer, first massage the string by padding it with ...

Rounding numbers in Perl

To round off the number we can usee sprintf. The f format lets you specify a particular number of decimal places ...

Converting between ASCII characters and values in perl

Most often developers want to print out the number represented by a given ASCII character, or print out an ASCII character ...

Exchange variables without temporary variable in perl

The most common approach to exchanging variables is to use a third temporary variable to swap content.$temp = ...

Defined function in perl

$x = defined($y) ? $y : $z;# use $y if $y is defined, else $zNote: Zero and space are considered true ...

quotemeta function in perl

The quotemeta() function adds backslashes in front of some predefined characters in a string. These predefined characters are: * period (.) ...

Perl documentation

Have you ever wonder where can we find information about various in-built Perl functions\subroutines? If yes then you can find the ...

Command line Perl Interpreter

If you want to execute a small piece of code then generally we create a 'pl' file and then execute the ...

Scalar function in perl

PERL's scalar function returns different output when used with lists. Example Using 'scalar' with arrays:...

eXTReMe Tracker