Re: Constant Hash problem

2005-12-20 Thread Andreas Pürzer
John W. Krahn schrieb: Kevin Old wrote: So to achieve an anonymous hash I'd have to do the following, correct? use constant STOPWORDS => { 'a' => 1, 'about' => 1, 'above' => 1, 'across' => 1,

Re: Constant Hash problem

2005-12-19 Thread John W. Krahn
Shawn Corey wrote: > John W. Krahn wrote: >> Shawn Corey wrote: >>> for my $key ( sort keys %{ { STOPWORDS } } ){ >>> my $value = ${ { STOPWORDS } }{$key}; >> >> >> In both lines you are copying the entire list to an anonymous hash. >> If you >> want efficient code (and less punctuation) you shou

Re: Constant Hash problem

2005-12-19 Thread Shawn Corey
John W. Krahn wrote: Shawn Corey wrote: for my $key ( sort keys %{ { STOPWORDS } } ){ my $value = ${ { STOPWORDS } }{$key}; In both lines you are copying the entire list to an anonymous hash. If you want efficient code (and less punctuation) you should just use a hash. Efficiency. There's

Re: Constant Hash problem

2005-12-19 Thread John W. Krahn
Kevin Old wrote: > On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: >>Kevin Old wrote: >>>On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: Kevin Old wrote: >I'm trying to define a constant hash and have the following: > >use constant STOPWORDS => map { lc $_ , 1 } qw(

Re: Constant Hash problem

2005-12-19 Thread Kevin Old
On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: > Kevin Old wrote: > > On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: > >>Kevin Old wrote: > >> > >>>I'm trying to define a constant hash and have the following: > >>> > >>>use constant STOPWORDS => map { lc $_ , 1 } qw(a about above acro

Re: Constant Hash problem

2005-12-17 Thread John W. Krahn
Shawn Corey wrote: > John W. Krahn wrote: >> You can't because perl implements constants using subroutines and >> subroutines >> can only return a list. > > Perl subroutines return only lists but it converts them to hashes > automatically: > > #!/usr/bin/perl > > use strict; > use warnings; > >

Re: Constant Hash problem

2005-12-17 Thread Shawn Corey
John W. Krahn wrote: You can't because perl implements constants using subroutines and subroutines can only return a list. Perl subroutines return only lists but it converts them to hashes automatically: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; sub list_to_hash { retu

Re: Constant Hash problem

2005-12-16 Thread John W. Krahn
Kevin Old wrote: > On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: >>Kevin Old wrote: >> >>>I'm trying to define a constant hash and have the following: >>> >>>use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj >>>after); >>> >>>I do not get a hash from this. >>You are d

Re: Constant Hash problem

2005-12-16 Thread Kevin Old
On 12/16/05, John W. Krahn <[EMAIL PROTECTED]> wrote: > Kevin Old wrote: > > Hello everyone, > > Hello, > > > I'm trying to define a constant hash and have the following: > > > > use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj > > after); > > > > I do not get a hash from th

Re: Constant Hash problem

2005-12-16 Thread John W. Krahn
Kevin Old wrote: > Hello everyone, Hello, > I'm trying to define a constant hash and have the following: > > use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj > after); > > I do not get a hash from this. You are defining STOPWORDS as a list. > This does work, however: >

Re: Constant Hash problem

2005-12-16 Thread Wiggins d'Anconia
Kevin Old wrote: > Hello everyone, > > I'm trying to define a constant hash and have the following: > > use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj > after); > > I do not get a hash from this. > > This does work, however: > > my %stopwords = map { lc $_ , 1 } qw(a

Constant Hash problem

2005-12-16 Thread Kevin Old
Hello everyone, I'm trying to define a constant hash and have the following: use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj after); I do not get a hash from this. This does work, however: my %stopwords = map { lc $_ , 1 } qw(a about above across adj after); use constan