home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!nuscc!ccechk
- From: ccechk@nuscc.nus.sg (Heng Kek)
- Newsgroups: comp.lang.perl
- Subject: Re: Assoc array indirection
- Message-ID: <1992Aug18.020219.28827@nuscc.nus.sg>
- Date: 18 Aug 92 02:02:19 GMT
- References: <1992Aug17.170850.13766@netlabs.com>
- Organization: National University of Singapore
- Lines: 32
-
- lwall@netlabs.com (Larry Wall) writes:
- : In article <1992Aug17.100513.9649@nuscc.nus.sg> ccechk@nuscc.nus.sg (Heng Kek) writes:
- ...[stuff deleted]...
- : : 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
- ...[stuff deleted]...
- : Why do you need the eval?
-
- I guess I (the original poster) didn't post a very good example for
- what I was trying to find out, in my hurried quest for a quick answer.
- Here's a better illustration as to why I needed the 'eval':
-
- #!/usr/bin/perl
- @host = ('nusunix1', 'nusunix2', 'nusunix3');
-
- $nusunix1{'john'} = '555/666/k ';
- $nusunix1{'mary'} = '666/777/l ';
- $nusunix1{'pete'} = '888/999/m ';
-
- @names = ('john', 'mary', 'pete');
-
- print eval "\@$host[0]{\@names[0..2]}"; # okay.
- print "\n";
- #print eval "\@$host[0]{@names[0..2]}"; # This doesn't work.
-
- The above works, thanks to all your responses.
-
-
- Sincerely
- Heng Kek
- National Univ of S'pore
-