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?

Please, give more info:
1. Why use LWP::Simple when there is really nothing the module is doing, since you are getting your names and ids from a text file called 'intput.txt',
2. You can also use the module CGI to generate your html files.
3. Also show how your input data are and what you want your output look like.
Thanks

Any simple ways to get hyperlinks using perl without the HTML table?

Yes. What's wrong with the example shown in the docs?

use LWP::Simple;
$content = get("http://www.sn.no/");

I assume that you want to retrieve the html content from the site refered to in a given hyperlink, right? If the components required to build the link are in a text file you can read the text file and put the components together to make a valid URL, which you can pass to the get method and assign the returned text to a variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.