/ Published in: Perl
A simple iterator that takes a tab-delimited file as input and prints an HTML document that contains the tabbed data.
Expand |
Embed | Plain Text
#! /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. # # # # # ############################################################ foreach my $one_line (@whole_file) { next if ($one_line =~ m/^\s*$/); #ignore blank lines next if ($one_line =~ m/^#/); #ignore lines starting with "#" print "\n"; #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 "\n"; } =item Here is an example data file: big fuzzy bear little orange kangaroo large grumpy koala small sleepy panda =cut
You need to login to post a comment.
