September 2002
Intermediate to advanced
496 pages
10h
English
The operators in this section are Perl operators not found in the C language.
The range operator is a pair of dots (..). It has many uses in Perl. Perhaps the most useful is to create a sequence of elements to fill an array. The code below sums the numbers in the range 1 to 100.
@numbers = (1..100); # the numbers 1, 2, 3,...,100
foreach $item (@numbers)
{
$sum += $item;
}
Rather than explicitly writing out the values in a particular sequence, the range operator generates them for you. This operator can be used with numbers or with characters. The code below prints the uppercase and lowercase characters.
foreach $item (a..z, A..Z);
{
print "$item";
}
Perl is very good at string manipulation. ...
Read now
Unlock full access