in reply to Read block of file and print to html table
I'll get you started with a simple parser. Not perfect, but a start.
Read about the CGI module (do a google search on CGI Perl) and adapt this to start generating html code.
Report back when you've made some attempts at that.
#!/usr/bin/perl -w use strict; use Data::Dump qw(pp); my %record=(); while (<DATA>) { if (/^Name/) { fill_in_record($_); process_record(); %record=(); } } sub fill_in_record { my $line = shift; while ( (defined $line) and $line !~ /^\s*$/ ) #stop on next blank #line or EOF { my ($id, $value) = split(' ',$line); chop $id; #this deletes the trailing ':' character $record{$id} = $value; $line =<DATA>; } } sub process_record { print "call cgi subroutine to process\n"; print pp (\%record),"\n"; print "\n"; } =prints call cgi subroutine to process { Name => "joe", age => 23, phone => 3423423 } call cgi subroutine to process { Name => "sam", age => 23, phone => 4343433 } call cgi subroutine to process { Name => "ram", ag => 45, phone => 34234232 } =cut __DATA__ some lines of code blah blah blah blah Name: joe age: 23 phone: 3423423 Name: sam age: 23 phone: 4343433 Name: ram age 45 phone: 34234232 some more lines.. blah blah..
|
|---|