Monthly Archives: August 2010

Env

Perl provides access to environment variables via the global “%ENV” hash. However, if using the ENV module, it will create global scalars for all the environment variables. use Env; print “$USER uses $SHELL”; If required to get only a few selected variables then it can be done like: use Env qw[@PATH $USER]; print “$USER’s path… Read More »

FindBin

Its usage is like: use FindBin; use lib “$FindBin::Bin/../lib”; or use FindBin qw($Bin); use lib “$Bin/../lib”;

Using hash for counting

When we have an array or a list of items and we want to find out the number of occurrences of a particular item then we generally use the following kind of logic: my $count = 0; for (@list) { $count++ if $_ eq “apple”; } This can be made better by using the grep… Read More »

Copying and Substituting Simultaneously

When the purpose is to search and replace a copy of the string and the intention is to accomplish this in one step then instead of doing this: $dst = $src; $dst =~ s/this/that/; a single step like this will be more concise: ($dst = $src) =~ s/this/that/;

WebAPP

WebAPP is a popular, open source Content Management System (cms) written in the Perl programming language. The name WebAPP is an abbreviation of Web Automated Perl Portal. Available under the GNU General Public License, WebAPP is free software. Features Enhanced crypt, Articles, Forums and nested message boards, Private Instant Messaging system (IM), Who is Online,… Read More »