Sunday, September 19, 2010
Why should I use the -w argument with my Perl programs?
This warning option turns on many warning messages that can help you understand and debug your applications.
To use this option on Unix systems, just include it on the first line of the program, like this:
#!/usr/bin/perl -w
If you develop Perl apps on a DOS/Windows computer, and you're creating a program named myApp.pl, you can turn on the warning messages when you run your program like this:
perl -w myApp.pl
Wednesday, August 11, 2010
Env
"%ENV" hash. However, if using the ENV module, it will create global scalars for all the environment variables.If required to get only a few selected variables then it can be done like:use Env;
print "$USER uses $SHELL";
use Env qw[@PATH $USER];print "$USER's path is @PATH";
FindBin
use FindBin;
use lib "$FindBin::Bin/../lib";
or
use FindBin qw($Bin);
use lib "$Bin/../lib";
Using hash for counting
my $count = 0;
for (@list) {
$count++ if $_ eq "apple";
} $count = grep $_ eq "apple", @list; $count_apples = grep $_ eq "apple", @list;
$count_pears = grep $_ eq "pear", @list; my %histogram;
$histogram{$_}++ for @list; $unique = keys %histogram;@popular = (sort { $histogram{$b} <=> $histogram{$a} }keys %histogram)[0..4];
Copying and Substituting Simultaneously
a single step like this will be more concise:$dst = $src;
$dst =~ s/this/that/;
($dst = $src) =~ s/this/that/;
WebAPP
WebAPP is the most fully-featured, versatile, free and open-source, flat-file Perl portal script available today! Acronym for Web Automated Perl Portal ™, WebAPP is easily installed on virtually any UNIX-based server. WebAPP requires no SQL backend, no PHP, only a hosting environment offering support for Perl.
Featuring the most complete (and growing) set of interactive community-building resources available, even an inexperienced webmaster can easily install WebAPP, login and personalize their portal, populate it with their content, and easily maintain, develop and administer the site.
Refer More http://www.web-app.net/
Thursday, March 4, 2010
difference between soft link and hard link
Hard Links :
1. All Links have same inode number.
2.ls -l command shows all the links with the link column(Second) shows No. of links.
3. Links have actual file contents
4.Removing any link just reduces the link count but doesn't affect other links.
Soft Links(Symbolic Links) :
1.Links have different inode numbers.
2. ls -l command shows all links with second column value 1 and the link points to original file.
3. Link has the path for original file and not the contents.
4.Removing soft link doesn't affect anything but removing original file the link becomes dangling link which points to nonexistant file.
Tuesday, February 9, 2010
Changing your default UNIX file permissions
To change the default permissions assigned to your UNIX files and directories, use the umask command. umask is a little confusing at first. Its format is
umask nnn
where nnn is a three-digit code that defines the new default permissions. The umask string does not have the same format as the the chmod permission string.
Each of the three numbers represents one of the categories user, group, and other. The value for a category is calculated as follows:
read permission has a value of 4
write permission has a value of 2
execute permission has a value of 1
Sum the permissions you want to set
for the category, then subtract that
value from 7.
As an example, examine the current default umask statement that is used to assign the file protections -rwx-r-x--- :
umask 027
The user category value is 0 because r+w+x = 4+2+1 = 7. When this is subtracted from 7, the value is 0.
The group category value is 2 because r+x = 4+1 = 5. When this is subtracted from 7, the value is 2.
The other category value is 7 because no permissions = 0. When this is subtracted from 7, the value is 7.