Path: newshog.newsread.com!bad-news.newsread.com!netaxs.com!newsread.com!newsfeed.mathworks.com!oleane.net!oleane!isdnet!diablo.theplanet.net!news.theplanet.net!newspost.theplanet.net!not-for-mail From: "Hugh Williams" <hugh@grugach.freeserve.co.uk> Newsgroups: comp.lang.perl.misc Subject: Behaviour of __PACKAGE__ inside eval Date: Mon, 22 Jan 2001 21:44:42 -0000 Organization: Customer of Energis Squared Lines: 36 Message-ID: <94i96o$q7f$1@news8.svr.pol.co.uk> NNTP-Posting-Host: modem-108.anfauglith.dialup.pol.co.uk X-Trace: news8.svr.pol.co.uk 980199448 26863 62.136.110.108 (22 Jan 2001 21:37:28 GMT) NNTP-Posting-Date: 22 Jan 2001 21:37:28 GMT X-Complaints-To: abuse@theplanet.net X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: bad-news.newsread.com comp.lang.perl.misc:373677 Hi, I found this strange bit of behaviour related to __PACKAGE__ and eval. The following bit of code: $a=1; package no2; $a=2; print __PACKAGE__."\n"; print "$a\n"; print "$main::a\n"; eval <<'--END--'; # note single quotes - no interpolation print __PACKAGE__."\n"; print "$a\n"; print "$main::a\n"; --END-- produces this output no2 2 1 main 2 1 so although the variable $a in the eval statement resolves in the expected namespace, the __PACKAGE__ symbol itself is inaccurate. Can anyone explain what is happening here? Thanks Hugh