in reply to Newbie Needs Help with Hash
First of all, it's a bad idea to use the variable names $a and $b in your code because they're special variables used by sort.
Secondly, you can write this:
foreach (@getcert) { $c = $_;
...as this:
foreach my $c (@getcert) {
To get your arrays into a hash, I'd use List::MoreUtils.
use List::MoreUtils qw( mesh ); my @users = qw( alice bob charlie ); my @ids = qw( 123 456 789 ); my %id_of = mesh @users, @ids; # now $id_of{ 'alice' } == 123
If you don't want to install List::MoreUtils, you could just paste in the source for mesh:
sub mesh (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\ +@\@\@) { my $max = -1; $max < $#$_ && ($max = $#$_) for @_; map { my $ix = $_; map $_->[$ix], @_; } 0..$max; }
Lastly, if you haven't already, consider "use strict;use warnings;".
|
|---|