Total Pageviews

Friday, April 13, 2012

Create an Array of Specific Numbers in Perl

@ft=(1 .. 14);
foreach $h(@ft) {
print "$h ";
}
Which Prints:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
-We created an array and named it ft because we don't like long names.
-We stored 1 through 14 in ft The two periods basically say "through".
-We used Perl's built-in foreach loop to loop over the array and print.
Free Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
@ft=(1 .. 14);
foreach $h(@ft) {
print "$h ";
}
exit;

No comments:

Post a Comment