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

I had posted my entire part of code .Help me to fix issue where i struck with.Thanks in advance

  • Comment on Re^2: How to add hyperlink for every table data using perl?

Replies are listed 'Best First'.
Re^3: How to add hyperlink for every table data using perl?
by huck (Prior) on Mar 10, 2017 at 05:43 UTC

    I dont understand this Help me to fix issue where i struck with.

    but im going to guess its at

    print $fh_out '<a href="'.$outfile{$word}.'">';
    that you are having problems. $outfile is a scalar my $outfile = "$dir/$root.html"; and not an hash so you can t"address into" it with {$word}. Now in $outfile also contains a filesystem name and not a http url. It is quite possible to change $outfile into a uri by knowing your web-server-root directory and changing that subsection at the beginning of $outfile to "http://some.server.name/", or just removing it and creating a relative (to the webserver) uri. But $outfile in itself is not a valid uri.

    But even then $outfile is the file you are writing to now, so i find it kinda hard to believe you want a hyperlink to the same webpage you are on now. Maybe you want to hyperlink to another section with a "#subpart" reference, or maybe you want to link to some other page than the one you are on now. But you still have not said where it is you want to link to.

    So, if you are printing what is contained in $word into the first column, just where is it that you want to link to. is it based on what is in $word (SL.NO)? Is it based on what goes into the columns CHECKLIST ITEM, or VALUE, or COMMENTS, or CONFIRMATION? if you can tell me what is the uri you want to link the row to, i can explain what to change $outfile{$word} to. If you can construct a variable containing a valid url, like  my $href="http:/some.server.name/$part1/$part2/$part3"; replaceing $part1, $part2, $part3 with some combination of $dir, $root, $ext, $data[0], $data[1], $data[2], $data[3],$data[4] just code it before the my $check=0; line and change print $fh_out '<a href="'.$outfile{$word}.'">'; to print $fh_out '<a href="'.$href.'">';

    and if that is all of your code, you are still have a lost </table>. i do see the <table> table and <th>...</th> header tags, but you should close your table too. It is nice to close the body and html tags as well, but less required. An unclosed table tag can present an error condition at times.

    But i am not a mindreader and i still dont know where you want to link to because you have not told me yet.

      Hi, the link is as follows: http://cad.psd.log.com/apps/dev/adkb/dc_checklist/DEMO/top/DV/
      Name Last modified Size Description [DIR] Parent Directory - [DIR] DV/ 07-Mar-2017 12:24 - [ ] block.config 07-Mar-2017 12:24 399 [ ] block.html 07-Mar-2017 12:24 1.6K
      http://cad.psd.log.com/apps/dev/adkb(this is the constant location in which directories are stored).

        That still doesnt help. but it is MUCH closer. when you want that link what is in $file and $line? If you tell me that we may be able to get this all put to bed. I dont know where dc_checklist, DEMO, top, and DV are coming from, but i assume they are somewhere in $file or $line

        edit: ok, maybe ive been reading this all wrong, do you want every link to be to http://cad.psd.log.com/apps/dev/adkb/dc_checklist/DEMO/top/DV/ ?

        then its just

        ... blahblahblah... my $href='http://cad.psd.log.com/apps/dev/adkb/dc_checklist/DEMO/top/D +V/'; my $check=0; for my $word(@data){ $check++; print $fh_out '<td>'; if($check==1) { print $fh_out '<a href="'.$href.'">'; } print $fh_out $word; if($check==1) { print $fh_out '</a>'; } print $fh_out '</td>'; } print $fh_out "</tr>\n"; } print $fh_out '</table></body></html>'."\n"; close $fh_out; }

      i want to link to the the file with its folder location.

        What does "the the file" mean? What does "its folder location" mean? What is the wab page you want to linkto based on "the the file with its folder location"? You want me to guess? Is this the link to the the file with its folder location?