Coder's Guild Mailing List

Re:Perl: Processing lists

Posted by Klenk@knuut.de on 1999-11-13

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Subject: Perl: Processing lists

Okay I have 2 lists, one which stores
>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 href=\"$link\">$desc</a><br>";
>}
>}

You should address on list with the foreach-loop and the other one ,
in that loop, as an array.

$count = 0;

foreach $desc (@desc){
    print "<a href=\"$link[$cout]\">$desc</a><br>";
    $count++;
}


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.1 for non-commercial use <http://www.pgp.com>
Comment: Trust No One!

iQA/AwUBOC1Uq2yUfrxnPBJNEQKWegCgi6EtpuJivBTzeZdgbO2M7+lR8akAmwX6
DAN0Rsmrsm6OvMHu6pkxs//S
=AyFo
-----END PGP SIGNATURE