Loading ...
Sorry, an error occurred while loading the content.

[PBML] Re: Perl: Processing lists

Expand Messages
  • David E Newman
    Frank, This is a clasic case for a hash. You may want to consider the URL as the key and the description as the value. One thing to note is the order may not
    Message 1 of 2 , Nov 12, 1999
    • 0 Attachment
      Frank,

      This is a clasic case for a hash. You may want to consider
      the URL as the key and the description as the value. One thing
      to note is the order may not be to you liking but you
      could always sort.

      # Declare and initialize web sites hash.

      my %web_sites = (
      http://www.yahoo.com => "Web search engine",
      http://www.pgsnys.org => "Polish Genealogy Site"
      );

      # Print out hash

      foreach my $url (%web_sites) {

      print "<a ref=\"$url\">$web_site{$url}</a><br>";

      }



      On Fri, 12 Nov 1999, Frank Hale wrote:

      > Okay I have 2 lists, one which stores URL's and
      > another which stores the description of the URL's. I
      > want to build up HTML code for these links but if I
      > use the following code it loops for a very long time
      > creating multiple copies of the same links. How can I
      > build up the list of links using the 2 lists?
      >
      > foreach $desc (@desc)
      > {
      > foreach $link (@links)
      > {
      > print "<a ref=\"$link\">$desc</a><br>";
      > }
      > }
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Bid and sell for free at http://auctions.yahoo.com
      >
      > ------------------------------------------------------------------------
      > Looking for the latest consumer electronic gadgets or computer
      > equipment? eBay has thousands of audio equipment, computer
      > games & accessories. You never know what you might find at eBay!
      > http://clickhere.egroups.com/click/1142
      >
      > -- Talk to your group with your own voice!
      > -- http://www.egroups.com/VoiceChatPage?listName=perl-beginner&m=1
      >
      >
      >

      ___________________ * _-_
      \==============_=_/ ____.---'---`---.____ *
      \_ \ \----._________.----/
      * \ \ / / `-_-' *
      * __,--`.`-'..'-_
      /____ || *
      `--.____,-' ...to boldly go where no man has gone before!

      _______________________________________
      _________| David Newman |________
      \ | E-Mail: | /
      \ | akdave@... | /
      \ | denewman@... | /
      \ | | /
      / | Web Page: | \
      / | http://www.oss.buffalo.eud/~denewman | \
      / |_______________________________________| \
      /___________) (__________\
    Your message has been successfully submitted and would be delivered to recipients shortly.