Re: I have the following code...please advise

by "Shaun L. Sides" <arch(at)charter.net>

 Date:  Wed, 28 Jun 2000 10:17:53 -0400
 To:  <hwg-languages(at)hwg.org>
 In-Reply-To:  chronotope
  todo: View Thread, Original
-----BEGIN PGP SIGNED MESSAGE-----

On 10 Jun 2000, at 23:09, christopher l. filkins wrote: 

> I have the following perl code and was hoping someone might 
show me a more 
> elegant way to do it. 
>  
> Please advise. 
>  
>  
>  
>  
> if ($ENV{"QUERY_STRING"} =~ /01000002/) 
>             { 
>     $page = "page.html?L+$track"; 
>             } 
> if ($ENV{"QUERY_STRING"} =~ /01000003/) 
>             { 
>     $page = "second_page.html?L+$track"; 
>             } 
> if ($ENV{"QUERY_STRING"} =~ /01000004/) 
>             { 
>     $page = "third_page.html?L+$track"; 
>             } 

I came up with this from page 689 of the Perl Cookbook. 

for($ENV{"QUERY_STRING"}) { 
  $page = /01000002/ && "page.html?L+$track" 
       || /01000003/ && "second_page.html?L+$track" 
       ||               "third_page.html?L+$track"; 
  } 

I tested it, and it seems to work the way it should. 

Hope it helps. 

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.2 -- QDPGP 2.61a
Comment: http://community.wow.net/grt/qdpgp.html

iQCVAwUBOVoJECEw9uEAOtM/AQH7yAP8DQxHEDPQf5IqxlhQHhy+8Qgn43EUONiC
3QSly+fxwL4zKFJ+wt7pTlgloak+JveLgztBBM8XfcJkBpKKEPRd/GX8aD01LcNr
IusRjHhcCRAXgwLb9QgJ5PR8I/tegRfJ1PVcTo2JS6GAu4AbWfyF2CgPRg3UYRqj
/fcV0S7d5dY=
=CLW1
-----END PGP SIGNATURE-----

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.