Hello everyone:
I have a question regarding how to use a subroutine to sort an array contains a list of strings
in this case country names.
The requirement is to pass array to subroutine by using hard reference(pointer)
I was able to passing pointer to the subroutine, but I can not figure out how
to sort the array alphabetically inside the subroutine and return sorted array and print newly sorted array out. Please give me some advises and suggestions.
use strict;
use warnings;
my @country = ("Russia", "China", "India", "Cuba");
my $arrayptr = \@country;
&sort_array($arrayptr);
sub sort_array
{
my($array_ptr) = @_;
sort (@$array_ptr); #line 24
}
I got error message says, "Useless use of sort in void context" at line 24
Jeff
3-21-07