#!/usr/bin/perl -w use strict; print "Content-type:text/html\n\n"; # Grab each line in reverse order open (NEWS, "; close(NEWS); # Your column names, in the order they appear in the file my @colNames = qw(time_stamp title date author news avatar); # Store the contents of the file in a data structure # (array of hashrefs) my @table = (); foreach my $article (@articles) { chomp $article; my @vals = split (/\|/, $article); # Assign each value to its column name, in a hash my %row = (); print< HTML foreach my $col (@colNames) { $row{$col} = shift @vals; print< $row{$col} HTML } print<
HTML # Add this row to the table, as a hashref push @table, \%row; }