I am trying to learn how to fetch hyperlinks using perl for an input list of names with ids. Here is what I have come up with so far. Am I heading in the right direction? Any simple ways to get hyperlinks using perl without the HTML table?
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
use Data::Dumper;
=cut
Use the IDs to create hyperlinks for names.
<a href="http://www.randomwebsite?term=ID">Name</a>
=cut
open(my $in,"/input.txt");
open(my $out, "/output.htm");
my $firstline = <$in>;
chomp $firstline;
print $out "Name\n";
while(<$in>){
# SET UP THE HTML TABLE
print $out "<table border='1'>";
my @links = split /\t/;
my $name = $links[1];
my $id = $links[2];
my $name2IDlink1 = '<a href="http://randomwebsiteId=';
my $name2IDlink2 = '">';
my $name2IDlink3 = '</a>';
my $idl = $name2IDlink1.$id.$name2IDlink2.$name.$name2IDlink3;
print $out "<tr><td>$idl</td></tr>";
#print Dumper("$idl");
print $out "</table>";
}
close $out;
Note: I am still in the process of writing this code and this is not the correct fair version. I just want to know if there are other ways to do this. Simpler or faster and easier?