Hi,
> > Hello all, > > I hope you can help, I have the following information > > > > > > Happy,[EMAIL PROTECTED], manager, $20000 > > Bob, [EMAIL PROTECTED], manager, $35000 > > Jim, [EMAIL PROTECTED], manager, $50000 > > Charles, [EMAIL PROTECTED], sales, $28000 > > Ann, [EMAIL PROTECTED], sales, $29000 > > > > How would I load the above into hashes? depends on how you want it in a hash if you'd want the keys to be their names, and the value an array ref of email, position and salary, this would work: my $hash; while(<INPUTFILE>){ my @list = split ','; $hash->{ shift @list } = \@list; } > > How would I sort the information by position in company? you probably want to look at the 'schwartzian transform' anyway, you can look this up in perlfaq 4, in the sub section "How do I sort an array by (anything)?" > > How would perform a simple task sush as the average salary for the > > managers? add all the salaries together and devide them by the number of managers. an example (assuming we did the 'hashing' as in my previous example) my $cnt; my $total; for my $key ( %$hash ) { if ( $hash->{$key}->[1] eq 'manager' ) { # the emp type $total += $hash->{$key}->[2]; # the salary ++$cnt; # the count next; } } print "The average salary is: ", $total/$cnt, "\n"; > > Please, if anyone could help > > > > Regards > > Dominic > > i have to say i didnt run the code, but the example should be fairly obvious i think good luck, Jos -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]