http://www.perlmonks.org?node_id=1059940


in reply to Parsing Text from a File to HTML Table

G'day anupchandu,

If the status and dates contain no spaces, a quick and dirty fix might be:

my $status = shift @cells; my $end = pop @cells; my $start = pop @cells; print "<td>$_</td>" for ($status, join(' ', @cells), $start, $end);

A more robust solution would be to work on the basis that the formats of the status and dates are known: if you match them, whatever is left in the middle is the company name. Here's an example:

# Do this once: my $status_re = qr{\w+}; my $date_re = qr{\d{2}-\w{3}-\d{4}}; my $log_re = qr{^($status_re)\s+(.*?)\s+($date_re)\s+($date_re)\R$}; ... # Do this in the while loop print "<td>$_</td>" for $line =~ $log_re;

As you can see from earlier responses, our ability to provide you with a definitive answer is hampered by the lack of information in your original post. A better question gets better answers: read the guidelines in "How do I post a question effectively?" to see how you could have improved on this.

-- Ken