develooper Front page | perl.beginners | Postings from February 2002

question output hash values

Thread Previous | Thread Next
From:
Keith A. Calaman
Date:
February 26, 2002 16:03
Subject:
question output hash values
Message ID:
ACEHJLEFEBHOIDOEECLCCEGCCJAA.keith@kcalaman.com

I am trying to read in a data file, sort it by a particular column and then
output the results column by column to an HTML document.  I have the below
code which is only printing out my first record.  Can someone try and point
me in the right direction where I can get it sorted and then output the
contents something like $value[1] $value[2] so I can work with each column
independantly.  If this doesn't make any sense please let me know I have
been spinning to get this accomplished and can figure out how to get it to
work.  Thanks.

__________________________________________________________


#!/usr/bin/perl -w

use diagnostics;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;

#declare form variables
my $query = CGI->new();
my $title = $query->param('title');
my $source = $query->param('source');
my $sourceurl = $query->param('sourceurl');
my $newsurl = $query->param('newsurl');
my $year = $query->param('year');
my $action= $query->param('action');
my $month = $query->param('month');
my $day = $query->param('day');
my $date = join('/', $month,$day,$year);
my $key = $query->param('key');
$db_key = time;
$dbfile ="post.txt";




open(DB,"$dbfile") or die "can't $dbfile: $!\n";

my @entry = <DB>;

for(@entry){my @fields=split/\|/;

my $v=$fields[0];

splice @fields,0,1;

map{$key{$v}.=" ". $_}@fields};

reverse sort keys %key;


foreach $key (reverse sort keys %key) {
    $value = $key{$key};
    # do something with $key and $value
}

 $see .= qq|  $value[1]\n|;


close DB;

close DB;



print <<EndOfHTML;
<html>
<body>

$value
$see

</body>
</html>

EndOfHTML



-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About