this program is stupid and gay, but i wnat constrctive criticism of what could be done more efficiently...
#!C:\perl\bin\perl -w
&alphasort("ben","bill","joe","john","gary","roy","steph");
sub firstName
{
my($fname) = shift(@_);
foreach (@_)
{
$fname=$fname ge $_ ? $_ : next;
}
return($fname);
}
sub alphasort
{
$numVals = @_;
my(@names) = @_;
my(%namelist);
for($i=1; $i<=$numVals; $i++)
{
$currentname = &firstName(@names);
$namelist{$i} = $currentname;
foreach (@names)
{
s/$currentname/zzzzzzzzzzzzzzzz/i;
}
}
while (($key, $value) = each %namelist)
{
print("$key....$value\n");
}
}
it calls alphasort which then will call a function that returns the smallest name in the array, sticks that name into the current loop var, then it replaces that name (and unfortunately all other identical without regard to case) with a bunch of z's. it places these values into an associative array which it then prints out.
some questions:
1-better way than making a bunch of z's?
(trying not to use external functions)
2-why does the hash print out like this?
6,4,1,3,7,2,5 ??????
seems like it starts on one end and is bouncing back and forth until it hits the center??? what's the point of this? (i'm sure there's a good one).