#! /usr/bin/perl -w
use strict;
#Time-stamp: <2005-01-12 11:30:05 NSussman>
############################################################
# #
# #
# #
# NOAH SUSSMAN #
# #
# Tabs To Targets #
# #
# Created Jan 12 2005 at 1:10am #
# #
# Given tab-delimited data, place each line into a #
# heredoc and print to STDOUT then go on to the #
# next line #
# #
# Ignore #commented lines and blank lines. #
# #
# #
############################################################
my $input_file= shift; #file containing tab-delimited data
open(TABBED_DATA_HANDLE, $input_file) || die("Couldn't open $input_file
");
chomp(my @whole_file=<TABBED_DATA_HANDLE>);
foreach my $one_line (@whole_file) {
next if ($one_line =~ m/^s*$/); #ignore blank lines
next if ($one_line =~ m/^#/); #ignore lines starting with "#"
my @record = split(/ /, $one_line);
print "
";
#Place targets in the heredoc.
print <<CODEFRAGMENT;
<!--////////////////$record[2] block of html////////////////////////////////////////////////////////////////-->
<tr>
<td class="smelly">$record[1]</td>
<td class="dogfood">$record[0]</td>
<td class="teaParty">$record[2]</td>
</tr>
<!--////////////////end of $record[2] block of html////////////////////////////////////////////////////////////////-->
CODEFRAGMENT
#end of heredoc.
print "
";
}
=item
Here is an example data file:
big fuzzy bear
little orange kangaroo
large grumpy koala
small sleepy panda
=cut
Wrap tab-delimited strings in HTML
Category: Uncategorized |
Tags: 2005, code, data, generator, heredoc, html, publish, tab-delimited, utilities
Leave a Reply
You must be logged in to post a comment.