Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: Using Perl to Implement a simple Searchable Web Database

by cjf (Parson)
on May 28, 2002 at 17:51 UTC ( [id://169856]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Using Perl to Implement a simple Searchable Web Database
in thread Using Perl to Implement a simple Searchable Web Database

This should get you started...

#!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; my $number_to_find = $q->param("number"); open DATA, "data.txt" or die "Can't open file: $!"; while (<DATA>) { chomp; my @fields = split /,/; if ($fields[0] eq $number_to_find) { print_to_browser(@fields); } } close DATA; sub print_to_browser { my @data = @_; print $q->header("text/html"), $q->start_html("Error"), $q->h1("Relevant Data"), $q->p(@data), $q->end_html; }

That's definately not the prettiest code, but it should give you an idea of what you need to do. You'll probably also want to read some of the CGI.pm docs and do a search or two on cpan for "CSV" to find some relevant modules.

  • Comment on Re: Re: Re: Using Perl to Implement a simple Searchable Web Database
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Using Perl to Implement a simple Searchable Web Database
by Anonymous Monk on May 28, 2002 at 18:28 UTC
    Thanks for your help, I just found out that the web server I am working on supports CGI and Perl (or so they say) I'll be testing it out to make sure. Thanks again! :-D

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://169856]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found