G'day finddata,

Welcome to the Monastery.

You have quite a few issues with your Perl and HTML code. In addition, there's important information missing from your post.

Based on your code, I made a very rough guess at what your input might look like. Here's the guts of what I think you probably want. You'll no doubt need to make quite a few changes, but this should be a sound starting point.

#!/usr/bin/perl -l use strict; use warnings; while (<DATA>) { chomp; s/(?:COMMENT|[&\\_@])//g; my @data = split /:/; print '<tr class="', $data[0] ? 'norm' : 'bold', '">', '<td>', join('</td><td>', @data[1,2]), '</td>', '<td><a href="#', $data[3], '">', $data[4], '</a></td></tr>'; } __DATA__ 0:A:B:frag1:name1 1:C:D:frag2:name2 0:E:F:fr&ag3:naCOMMENTme3 1:G:H:fr\ag4:_name4 0:I:J:fr@ag5:name5

Output:

<tr class="bold"><td>A</td><td>B</td><td><a href="#frag1">name1</a></t +d></tr> <tr class="norm"><td>C</td><td>D</td><td><a href="#frag2">name2</a></t +d></tr> <tr class="bold"><td>E</td><td>F</td><td><a href="#frag3">name3</a></t +d></tr> <tr class="norm"><td>G</td><td>H</td><td><a href="#frag4">name4</a></t +d></tr> <tr class="bold"><td>I</td><td>J</td><td><a href="#frag5">name5</a></t +d></tr>

— Ken


In reply to Re: How to add hyperlink for every table data using perl? by kcott
in thread How to add hyperlink for every table data using perl? by finddata

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.