On Sun, May 3, 2009 at 11:36 PM, Chris Prather <perig...@gmail.com> wrote:

> On Sun, May 3, 2009 at 11:56 PM, fREW Schmidt <fri...@gmail.com> wrote:
> > On Sun, May 3, 2009 at 2:22 PM, Hans Dieter Pearcey <h...@pobox.com>
> wrote:
> >
> >> On Sun, May 03, 2009 at 10:24:54AM -0500, fREW Schmidt wrote:
> >> >       [ %{$data}->values->map->(sub { $_ + 1  }) ]
> >>
> >> don't dereference $data; your sanity check example uses a hashref, not a
> >> hash,
> >> so it works fine.
> >
> >
> > I must be missing something, because I tried that and it still doesn't
> > work.  To be clear, here's the class:
>
> Check your assumptions again because:
>
> $ perl -MMoose::Autobox -E '{ foo => q[bar]  }->values->print'
> bar
>
> $ perl -MMoose::Autobox -E '{ foo => 1  }->values->map(sub { $_ + 1
> })->print'
> 2
>
> # perl -MMoose::Autobox -E 'my $d = { foo => 1  }; $d->values->map(sub
> { $_ + 1 })->print'
> 2
>
> $ perl -MMoose::Autobox -Moose -e 'sub foo { my $d = { f => 1 };
> $d->values->map(sub { $_ + 1 })->print }; package main;
> Class->new->foo()'
> 2
>
> $ perl -MMoose::Autobox -MMooseX::Declare -E 'class F { method foo {
> my $d = { foo => 1  }; $d->values->map(sub { $_ + 1 })->print } }
> F->new()->foo'
> 2
>
> Perhaps Method::Signatures isn't doing what you think?
>

Yeah, I wanted to replace that with MooseX::Method::Signatures, but I can't
because CPAN is failing on installing Variable::Magic.  Either way though, I
don't think that's causing the problem.  Here's some simpler code that
doesn't use the Method stuff:

package Foo;
use Moose;
use Moose::Autobox;

sub foo {
   return [ (1, 2)->map->(sub { $_ + 1  }) ];
}

1;

and the test:

#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 2;
BEGIN { use_ok 'Foo' };
my $foo = Foo->new();
is_deeply $foo->foo, [ 2, 3 ], 'test';

Error:

Can't call method "map" without a package or object reference

I am totally at a loss.  Why would this simple case not work in a class, but
work in a regular script?

-- 
fREW Schmidt
http://blog.afoolishmanifesto.com

Reply via email to