Array Library Functions
#!/usr/local/bin/perl
#program that uses array library functions to
# sort, reverse, merge, and split an array
# read the array from standard input one item at a time
print ("Enter the array to sort, one item at a time.\n");
print ("Enter an empty line to quit.\n");
$count = 1;
$inputline = <STDIN>;
chop ($inputline);
while ($inputline ne "") {
@array[$count-1] = $inputline;
$count += 1;
$inputline = <STDIN>;
chop ($inputline);
}
# now sort and print the array
@array = sort (@array);
print ("The sorted array is: @array\n");
# now reverse and print the array
@array = reverse (@array);
print ("The reversed array is: @array\n");
# now join and print the array
$string = join ("::", @array);
print ("The joined array is: $string\n");
# now split and print the array
@array = split (/::/, $string);
print ("@array\n");