in reply to Read block of file and print to html table
use strict; use warnings; my ($handle, $data); open($handle, 'data.txt'); $data = join '', <$handle>; close($handle); open($handle, '>data.html'); print $handle qq| <table cellspacing="0" cellpadding="8" border="0"><tr> <td><b>Name</b></td> <td><b>Age</b></td> <td><b>Phone</b></td>|; while ($data =~ /Name:? ?(.*?)\nAge:? ?(.*?)\nPhone:? ?(.*?)\n/igs) { print $handle qq| </tr><tr> <td>$1</td> <td>$2</td> <td>$3</td>|; } print $handle qq| </tr></table>|; close($handle);
|
|---|