_%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,4}\
This is just a taste of how to use regular expressions in Perl. Read over the perlrequick
and perlretut man pages for a more in-depth look, or check out Teach Yourself Regular
Expressions in 10 Minutes by Ben Forta and published by Sams Publishing.
Perl Command Line Arguments
As with shell scripts, Perl allows you to extract arguments entered on the command line
when the script is run. Perl places any supplied arguments into the array ARGV. You can
reference each individual argument using the appropriate array element (in Perl, arguments
start at zero).
Here??™s an example of a using an argument in a Perl script:
#!/usr/bin/perl
# leap.pl - determine if a specified year is a leap year
if ($ARGV[0])
{
$year = $ARGV[0];
if (( $year % 4 == 0) xor ( $year % 100 == 0 ) xor ( $year % 400 == 0 ) )
{
print ???$year is a leap year\n???;
Perl Programming 617
30
} else
{
print ???$year is not a leap year\n???;
}
} else
{
print ???Sorry, you did not provide a year.\n???;
}
The leap.pl script accepts a year value as a single argument on the command line and
then determines if the year is a leap year.
Pages:
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174