malaga has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl use Data::Dumper; use strict; use CGI qw/:standard/; my $value = $cgi->param('value'); open FILE , "facultydummy.txt" or die "Cannot open: $!"; #my $rowid = $ARGV[0] || '$roy'; my $rowid = $ARGV[0] || 'value'; my %data = (); my @fields = split(/\t/, <FILE>); chomp @fields; while(<FILE>) { chomp; my @row = split(/\t/); if ($row[0] eq $rowid) { @data{@fields} = @row; last; } } print "Content-type: text/html\n\n"; if ( keys %data ) { # found, display data print Dumper \%data; } else { # not found, show error print STDERR "Can't find row '$rowid'\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI PM
by Fastolfe (Vicar) on Jan 28, 2001 at 23:22 UTC | |
by malaga (Pilgrim) on Jan 28, 2001 at 23:33 UTC | |
by OeufMayo (Curate) on Jan 29, 2001 at 00:51 UTC | |
by malaga (Pilgrim) on Jan 29, 2001 at 01:05 UTC | |
by chromatic (Archbishop) on Jan 29, 2001 at 01:30 UTC | |
by eg (Friar) on Jan 29, 2001 at 01:30 UTC |