Native Perl Operators
The operators in this section are Perl operators not found in the C language.
Range Operator
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"; }
String Operators
Perl is very good at string manipulation. ...
Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.