Month: March 2009

Error : Can’t do inplace edit without backup

I am writing a command line perl program to replacetextcontentina file .I know that the following instruction executes successfully on one of the unix machine. [...]

Special Variables – @ARGV

@ARGV Short Name   :         @ARGV Scope           :          always global This variable is an array of the arguments passed [...]

Perl Handles Numbers

Perl can handle both whole numbers (integers, like 37) and floating-point numbers (real numbers with decimal points, like 17.5 or -235.2). Internally, Perl [...]

Basic Naming Rules in Perl

Variable names can start with a letter, a number, or an underscore, although they normally begin with a letter and can then be composed of any combination of [...]

Printing a Hash

################### #Solution1 : ################### while(($key,$value) = each%hash){ print"$k => $vn"; } ################ #Solution2 [...]

How to Take a Hash Slice

Assign some variables of a hash to an array. i.e you want to take some of the elements from hash based on there keys into a array here is a trick   %hash [...]

Establishing a Default Value

# # # # use $b if $b is true, else $c $a = $b || $c; # set $x to $y unless $x is already true $x ||= $y # use $b if $b is defined, else $c $a = defined($b) ? [...]

Get Pathname Of Current Working Directory

Windows use File::Spec; my $current_directory = File::Spec->rel2abs("."); print $current_directory; Unix use Cwd; my $current_directory = getcwd; print [...]

Ordered Hashes In Perl

Perl hashes have no internal order. A hash consists of a number of "buckets''. When a record is inserted into the hash, the key is transformed, using a "hash [...]

How many ways can we express string in Perl

Many. For example 'this is a string' can be expressed in: "this is a string" qq/this is a string like double-quoted string/ qq^this is a string like [...]