home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5341 < prev    next >
Encoding:
Text File  |  1992-08-16  |  959 b   |  35 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!wupost!darwin.sura.net!jvnc.net!nuscc!ccechk
  3. From: ccechk@nuscc.nus.sg (Heng Kek)
  4. Subject: Assoc array indirection
  5. Message-ID: <1992Aug17.100513.9649@nuscc.nus.sg>
  6. Organization: National University of Singapore
  7. Date: Mon, 17 Aug 1992 10:05:13 GMT
  8. Lines: 25
  9.  
  10. Greetings
  11.  
  12. #!/usr/bin/perl
  13.   %ipaddr = ('nusunix1','137.132.73.11',
  14.              'nusunix2','137.132.10.11',
  15.              'nusunix3','137.132.91.12'
  16.             );
  17.   @host   = ('nusunix1',
  18.              'nusunix2',
  19.              'nusunix3'
  20.             );
  21. print eval "\@ipaddr{@host[0..1]}";              # no go
  22. print eval "\@ipaddr{join(',', @host[0..1])}";  # no go
  23. print eval "\@ipaddr{$host[0], $host[1]}";      # okay
  24.  
  25. Why doesn't the 1st 2 print()s do what I expect?  How do I achieve
  26. my goal, given my intentions in:
  27.  
  28. print eval "\@ipaddr{join(',', @host[0..1])}";  # no go
  29. ?
  30.  
  31. Or is it just wishful thinking?
  32. Hope someone can help.  Thanks
  33.  
  34. Heng Kek
  35.