Hello Monks

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".


In reply to Getting CGI parameters. by stalkeyefly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.