develooper Front page | perl.perl5.porters | Postings from August 2009

Re: [DOC] Modernization: perlsyn

Thread Previous | Thread Next
From:
Paul LeoNerd Evans
Date:
August 31, 2009 13:05
Subject:
Re: [DOC] Modernization: perlsyn
Message ID:
20090831210523.709b585a@nim.leo
On Sun, 30 Aug 2009 23:47:32 +0200
Elizabeth Mattijsen <liz@dijkmat.nl> wrote:

> Should we mention that you can write any variable like $foo also as $ 
> {foo}?  Or even as ${"foo"} if you don't have strict enabled?
> 

Not strictly true (pardon the pun):

$ perl -e 'no strict; my $foo = 10; print ${"foo"}'

$ perl -e 'no strict; my $foo = 10; print ${foo}'
10


${"foo"} is a soft reference to the SCALAR part of a symbol called "foo"
in the current package.  my $foo  does not create a package symbol, only
a lexical one.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About