Re: Quoting hash keys changes things sometimes

2008-11-20 Thread Brian McCauley
On Nov 15, 6:52 pm, [EMAIL PROTECTED] (Kelly Jones) wrote: > Consider: > > perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' > [no result] > > perl -le '$hash{"foobar"} = 1; print $hash{foobar}' > 1 > > I sort of understand this: in the first script, Perl treats foo-bar as > a subtraction, and

Re: Quoting hash keys changes things sometimes

2008-11-19 Thread Rob Dixon
Dr.Ruud wrote: > Rob Dixon schreef: >> Kelly Jones: >>> >>> Consider: >>> >>> perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' >>> [no result] >>> >>> perl -le '$hash{"foobar"} = 1; print $hash{foobar}' >>> 1 >>> >>> I sort of understand this: in the first script, Perl treats foo-bar >>> as a

Re: Quoting hash keys changes things sometimes

2008-11-16 Thread Dr.Ruud
Rob Dixon schreef: > Kelly Jones: >> Consider: >> >> perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' >> [no result] >> >> perl -le '$hash{"foobar"} = 1; print $hash{foobar}' >> 1 >> >> I sort of understand this: in the first script, Perl treats foo-bar >> as a subtraction, and sets $hash{

Re: [PBML] Quoting hash keys changes things sometimes

2008-11-15 Thread Chas. Owens
On Sat, Nov 15, 2008 at 17:42, Jenda Krynicky <[EMAIL PROTECTED]> wrote: snip > The rule for automatic quoting within $hash{...} is "if it looks like > word, it doesn't have to be quoted". And - is not in the list of word > characters as far as Perl is concerned. snip Not exactly. A hyphen is all

Re: Quoting hash keys changes things sometimes

2008-11-15 Thread Rob Dixon
Kelly Jones wrote: > Consider: > > perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' > [no result] > > perl -le '$hash{"foobar"} = 1; print $hash{foobar}' > 1 > > I sort of understand this: in the first script, Perl treats foo-bar as > a subtraction, and sets $hash{0} to 1. In the second one

Re: [PBML] Quoting hash keys changes things sometimes

2008-11-15 Thread Jenda Krynicky
From: "Kelly Jones" <[EMAIL PROTECTED]> > Consider: > > perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' > [no result] > > perl -le '$hash{"foobar"} = 1; print $hash{foobar}' > 1 > > I sort of understand this: in the first script, Perl treats foo-bar as > a subtraction, and sets $hash{0} to

Re: Quoting hash keys changes things sometimes

2008-11-15 Thread Chas. Owens
On Sat, Nov 15, 2008 at 15:10, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > s/pargmas/pragmas/; snip And I had paragams at one point. I need more (or better) sleep. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail:

Re: Quoting hash keys changes things sometimes

2008-11-15 Thread John W. Krahn
Chas. Owens wrote: On Sat, Nov 15, 2008 at 13:52, Kelly Jones <[EMAIL PROTECTED]> wrote: Consider: perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' [no result] perl -le '$hash{"foobar"} = 1; print $hash{foobar}' 1 I sort of understand this: in the first script, Perl treats foo-bar as a s

Re: Quoting hash keys changes things sometimes

2008-11-15 Thread John W. Krahn
Kelly Jones wrote: Consider: perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' [no result] Using warnings and/or strict may have helped: $ perl -Mwarnings -le 'my %hash = ("foo-bar", 1); print $hash{foo-bar}' Unquoted string "foo" may clash with future reserved word at -e line 1. Argument

Re: Quoting hash keys changes things sometimes

2008-11-15 Thread Chas. Owens
On Sat, Nov 15, 2008 at 13:52, Kelly Jones <[EMAIL PROTECTED]> wrote: > Consider: > > perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' > [no result] > > perl -le '$hash{"foobar"} = 1; print $hash{foobar}' > 1 > > I sort of understand this: in the first script, Perl treats foo-bar as > a subtra

Quoting hash keys changes things sometimes

2008-11-15 Thread Kelly Jones
Consider: perl -le '$hash{"foo-bar"} = 1; print $hash{foo-bar}' [no result] perl -le '$hash{"foobar"} = 1; print $hash{foobar}' 1 I sort of understand this: in the first script, Perl treats foo-bar as a subtraction, and sets $hash{0} to 1. In the second one it assumes you just left off some quot