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,
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
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
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(
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
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;
>
>
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
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
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
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:
>
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
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
12 matches
Mail list logo