Mailing List Archive

Lexical variables and package prefixes
Re: Lexical variables and package prefixes [ In reply to ]
Ken Fox writes:
>
>
> I was surprised that lexicals don't work with package prefixes. This
> example demonstrates:
>

You are missing something:

monk:~->perl -le 'my $i=5; package A; print $i'
5

Lexical have nothing to do with packages.

Ilya
Re: Lexical variables and package prefixes [ In reply to ]
Re: Lexical variables and package prefixes [ In reply to ]
Re: Lexical variables and package prefixes [ In reply to ]
>From: Ilya Zakharevich <ilya@math.ohio-state.edu>
>Message-Id: <199511210024.TAA04609@monk.mps.ohio-state.edu>
>Subject: Re: Lexical variables and package prefixes
>To: kfox@ford.com (Ken Fox)
>Date: Mon, 20 Nov 1995 19:24:49 -0500 (EST)
>
>Ken Fox writes:
>>
>>
>> I was surprised that lexicals don't work with package prefixes. This
>> example demonstrates:
>>
>
>You are missing something:
>
>monk:~->perl -le 'my $i=5; package A; print $i'
>5
>
>Lexical have nothing to do with packages.

Yes, this is a common mistake. I've tried to mention this in the next
version of the manual under my(), for which I got a patch to Andy a few
days ago. It's about 40% of the way through updating the old stuff.

--tom
Re: Lexical variables and package prefixes [ In reply to ]