#!/usr/bin/perl use strict; use warnings; my $file = "p2iextact.txt"; my %p2i; my @user_array; my $sp; my $ipr; my $key; my $user; # creates hash of arrays -okay works open(FILE, "p2iextact.txt") || die "can't open file"; while() { chomp; ($sp, $ipr) = split; if (exists $p2i{$sp}) { push @{$p2i{$sp}}, $ipr; # bareword {sp} hours of error }else { $p2i{$sp}= [$ipr]; } } close FILE; # test to see if hash created correctly - works also foreach $key (sort keys %p2i) { print "$key\t @{$p2i{$key}}\n"; #print "$key\t$p2i{$key}\n"; } } #### code that needs work ###### ### get user to enter info $user an id #### print "Please enter an ID: "; chomp( $user = ); $user = uc($user); if (exists $p2i{$user}) { print "$user is in the hash. \n"; print "$user: @{ $p2i{$user} }\n"; }else { print "$user is not in the hash.\n"; } exit; # Now I'm passing the $user id and their preference # about data managment and printing them back to the # screen for the user like this... print $query->header; print $query->start_html (-title=>'results', -style=>{'src'=>'/~campus1jle/JoGOCSS.css'} ); print "

The swissprot id you entered was: ", "
"; print $query->param('user'), "
";"
"; print "You have chosen to sort by", "
"; print $query->param('sort'), "
";"
"; # BUT for some reason I don't seem to be able to get # passing the $user to the code and passing back the # array working.