stalkeyefly has asked for the wisdom of the Perl Monks concerning the following question:
I'm tyring ot create some web-based resources to allow the data produce by the group that I'm working in to be more easily avalible to the rest of the scientific community. Been working on this particular tool for a couple of weeks. I have many of the subroutiines running in UINX using the key board. BUT I want to get them running from a webpage.
The code below is tested and runs as it should on UNIX with STDIN. I have become confused about How do I pass this variable as $user to the code below.... and how to pass the array back (but given the first bit of infromation I should be less confussed about the second.Cheers for any help - the first part of the code is just back end stuff.... but it might help in getting to overall picture.
#!/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(<FILE>) { 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 = <STDIN>); $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 "<p>The swissprot id you entered was: ", "<br />"; print $query->param('user'), "<br />";"<br />"; print "You have chosen to sort by", "<br />"; print $query->param('sort'), "<br />";"<br />"; # 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.
I have the feeling that this is a really generic question - but I can't quite see the wood for the trees at present having tried a couple of things that I was sure would work -then making random alterations to these thought though ideas in the hope that things might magical start working.
Cheers
Stalky
Edit by BazB: retitle from "CGI/PERL problem".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting CGI parameters
by PodMaster (Abbot) on Jun 25, 2004 at 13:41 UTC | |
|
Re: Getting CGI parameters
by zentara (Cardinal) on Jun 25, 2004 at 14:16 UTC |