develooper Front page | perl.perl5.porters | Postings from July 2012

Should can can?

Thread Next
From:
H.Merijn Brand
Date:
July 7, 2012 06:20
Subject:
Should can can?
Message ID:
20120707152029.31e3ef75@pc09.procura.nl
$ cat test.pl
use v5.14.1;
use warnings;

tie my $foo, "Foo";

say tied $foo;
say ref  $foo;
say $foo->can ("FETCH");

package Foo;

use strict;
use warnings;

require Tie::Scalar;
use vars qw( @ISA );
@ISA = qw(Tie::Scalar);

sub FETCH
{
    [ "#", 1 .. 3 ];
    } # FETCH

sub TIESCALAR
{
    bless [], "Foo";
    } # TIESCALAR

1;
$ perl test.pl
Foo=ARRAY(0x81a220c)
ARRAY
Can't call method "can" on unblessed reference at test.pl line 9.


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.14   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About