[kamloops-pm] Hello

Bradley K. Embree bke at bkecc.com
Thu Oct 9 15:11:21 CDT 2003


	use strict;
	use warnings;

	my %hash = ( foo => 'foo',
             	 bar => 'bar',
             	 zed => 'zed'
           	     );

	my $foo = 'bar';
	sub foo { return 'zed' }

	print $hash{ foo   }, "\n";
	print $hash{ $foo  }, "\n";
	print $hash{ &foo  }, "\n"; # or $hash{ foo() } or $hash{ &foo() }


Perl does make it very easy to write confusing code.  ;)

Brad

> -----Original Message-----
> From: kamloops-pm-bounces at mail.pm.org
> [mailto:kamloops-pm-bounces at mail.pm.org]On Behalf Of the only gay eskimo
> Sent: Thursday, October 09, 2003 12:53 PM
> To: Kamloops Perl Mongers
> Subject: Re: [kamloops-pm] Hello
> 
> 
> 
> for some reason, i thought strict would complain about it, or at least i
> remember it did. i was thinking that if you had a sub called 'ID' it'd get
> confused, but i just tested, and it's not the case
> 
> 
> > 
> > I.E. $row->{ID} is acceptable although I prefer and use 
> $row->{'ID'} as a form
> > of defensive programming.
> > 
> > Bare words are also acceptable when declaring hashes using the => 
> notation:
> > 
> > 	my %hash = ( foo => 'bar' ); # ok under strict
> > 	my %hash = ( foo, 'bar' );   # not ok under strict
> > 	my %hash = ( 'foo', 'bar' ); # ok under strict
> > 
> > but once again TMTOWTDI.
> > 
> > Brad
> > 
> _______________________________________________
> kamloops-pm mailing list
> kamloops-pm at mail.pm.org
> http://mail.pm.org/mailman/listinfo/kamloops-pm



More information about the kamloops-pm mailing list