home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!wupost!darwin.sura.net!jvnc.net!nuscc!ccechk
- From: ccechk@nuscc.nus.sg (Heng Kek)
- Subject: Assoc array indirection
- Message-ID: <1992Aug17.100513.9649@nuscc.nus.sg>
- Organization: National University of Singapore
- Date: Mon, 17 Aug 1992 10:05:13 GMT
- Lines: 25
-
- Greetings
-
- #!/usr/bin/perl
- %ipaddr = ('nusunix1','137.132.73.11',
- 'nusunix2','137.132.10.11',
- 'nusunix3','137.132.91.12'
- );
- @host = ('nusunix1',
- 'nusunix2',
- 'nusunix3'
- );
- print eval "\@ipaddr{@host[0..1]}"; # no go
- print eval "\@ipaddr{join(',', @host[0..1])}"; # no go
- print eval "\@ipaddr{$host[0], $host[1]}"; # okay
-
- Why doesn't the 1st 2 print()s do what I expect? How do I achieve
- my goal, given my intentions in:
-
- print eval "\@ipaddr{join(',', @host[0..1])}"; # no go
- ?
-
- Or is it just wishful thinking?
- Hope someone can help. Thanks
-
- Heng Kek
-