Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Parsing Text from a File to HTML Table

by kcott (Abbot)
on Oct 28, 2013 at 02:56 UTC ( #1059940=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Parsing Text from a File to HTML Table
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059940]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-12-19 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (74 votes), past polls