home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!munnari.oz.au!metro!usage!news
- From: cameron@cs.unsw.oz.au
- Subject: tell me this is a feature ...
- Message-ID: <cameron-921215144455-1-12966@fuligin>
- Sender: news@usage.csd.unsw.OZ.AU
- Nntp-Posting-Host: fuligin.spectrum.cs.unsw.oz.au
- Reply-To: cameron@cs.unsw.oz.au
- Organization: CS&E Computing Facility, Uni Of NSW, Oz
- Errors-To: cameron@cs.unsw.oz.au
- Date: Tue, 15 Dec 1992 03:45:15 GMT
- Return-Receipt-To: cameron@cs.unsw.oz.au
- Lines: 42
-
- For the record, this is using perl-4.034.
-
- Intending to check out a particular semantic of Perl I wrote the following
- (broken) script, which uncovered another semantic I had never encountered.
-
- $hdrs{'foo'}='fooval';
-
- { local(%hdrs);
-
- $hdrs{'foo'}='subfooval';
-
- print "foo=$hdrs{'fooval'}\n";
-
- undef $hdrs{'foo'};
-
- print "foo=$hdrs{'fooval'}\n";
-
- undef %hdrs;
-
- print "foo=$hdrs{'fooval'}\n";
- }
-
- print "foo=$hdrs{'fooval'}\n";
-
- What I was intending was to check that the original %hdrs got restored outside
- the block but the script doesn't check that because I mistyped the key in the
- print statements. I was, however, surprised by what the script did do, which
- was this:
- foo=
- foo=
- foo={'fooval'}
- foo=
-
- Notice the third line. This suggests that when resolving
- $thing{index}
- inside double quotes perl looks for %thing being defined before snarfing the
- curly portion. Weird, eh?
- - Cameron Simpson
- cameron@cs.unsw.oz.au, DoD 0743
- --
- "The engine purrs beneath me with a purpose,
- ready for the pleasure of my hand upon the throttle." - Peter Smith
-