To Reverse an Array in Perl
To reverse an array in Perl:
@gy=("Paris", "London", "Tokyo");
@gy=reverse(@gy);
print @gy;
Which Prints:
TokyoLondonParis
-We named our array
gy because we don't like typing long array names.
-We said to
reverse the array
gy and store it back into
gy.
-We said to print
gy which now has put our array in reverse order.
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
@gy=("Paris", "London", "Tokyo");
@gy=reverse(@gy);
print @gy;
exit;
Resources:
To Sort an Array in Perl
Splitting an ARRAY in Perl
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | Dojo Matthew A. Russell... | |
| | | CSS David McFarland |
| | | |