1. With Perl, command-line arguments are stored in the array named @ARGV.
#!/usr/bin/perl
#———————#
PROGRAM: argv.pl
#———————#
$numArgs = $#ARGV + 1;
print “thanks, you gave me $numArgs command-line arguments:/n”;
foreach $argnum (0 .. $#ARGV) {
print “$ARGV[$argnum]/n”;
}
result :
[root@localhost perl]# ./argv.pl 2 2 2 fd
thanks, you gave me 4 command-line arguments:
2
2
2
fd
2. Scalar variables
$priority = 9;
$priority = ‘high’;
$priority = ‘9’;
$default = ‘0009’;
[root@localhost perl]# cat basic.pl
#!/usr/bin/perl
#———————#
PROGRAM: basic.pl
#———————#
$a = ‘fff’;
$b = ‘x’;
$c = 3;
print ‘$a and $b’;
print “/n”;
print “$a and $b”;
print “/n”;
print $a . $c;
print “/n”;
print $a x $c;
print “/n”;
result :
[root@localhost perl]# perl basic.pl
$a and $b
fff and x
fff3
fffffffff
3. reg
http://www.comp.leeds.ac.uk/Perl/matching.html
4. subroutine
http://www.comp.leeds.ac.uk/Perl/subroutines.html