Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating hyperlinked lists

Status
Not open for further replies.

valicon

MIS
Sep 26, 2000
125
US
I am trying to write a program in perl that will read my
data from a text file, parse it, and then format it out
on my webpage as hyperlinks and in alphabetical order.
However, all the books that I have, not one tells me how
to turn the text in the text file into a hyperlink and
sort it alphabetically. Please help!
 
If your text file is pipe delimited.... looks like.......

Code:
URL | URL-label 
[URL unfurl="true"]http://www.someServer.com/|Link[/URL] to Some Server
[URL unfurl="true"]http://anotherServer.com|Link[/URL] to another server

and is named URLs.txt

Then,
Code:
#!/usr/local/bin/perl -w
# print normal html stuff to get page going
print "Content-Type: text/html\n\n";
print '<HTML><HEAD><TITLE>title here</TITLE></HEAD><BODY><P>';

# read the input file
open(IPF,&quot;<URLs.txt&quot;) or die;
while ($line = <IPF>) 
  {
  chop ($line);
  @fields = split(/\|/,$line);
  print '<a href=&quot;'.&quot;$fields[0]&quot;.'&quot;>'.&quot;$fields[1]&quot;.'</a><BR>';  
  }
close IPF;
print '</P></BODY></HTML>';

I typed this here and have not run it.....might have a minor typo....;^) but you get the ideas I hope.

'good luck [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
 
That helped more than one person, goBoating. Thanks for that.

-Vic [sig]<p>vic cherubini<br><a href=mailto:malice365@hotmail.com>malice365@hotmail.com</a><br><a href= software</a><br>====<br>
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director<br>
Wants to Know: Java, Cold Fusion, Tcl/TK<br>
====[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top