undcemcs02.und.edu
Example.pl
01
#!/usr/bin/perl
02
# Perl program to illustrate iteration through an array
03
04
# array creation
05
@arr
= ( 11, 22, 33, 44, 55 );
06
07
# Iterating through the range
08
print
(
"Iterating through range:\n"
);
09
10
# size of array
11
$len
=
;
12
13
for
$b
= 0;
<
+ 1 ) {
14
"\@arr[$b] = $arr[$b]\n"
15
}
16
17
# Iterating through loops
18
"\nIterating through loops:\n"
19
20
# foreach loop
21
foreach
$a
) {
"$a "
; }
undcemcs02> /usr/bin/perl Example.pl
undcemcs02>