Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^6: Stuck on packages

by Yoda_Oz (Sexton)
on Jan 04, 2007 at 07:21 UTC ( #592897=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Stuck on packages
in thread Stuck on packages

ARRAY(0x18012b8) is the output.
here is the entire code:

#!/usr/bin/perl package Foo; sub new { my $class = shift; return bless { engine => "engine", wheels => "wheels" }, $class; } sub get_as_array { my $self = shift; return [ $self->{engine}, $self->{wheels} ]; } 1; my $foo = Foo->new; print $foo->get_as_array;


Comment on Re^6: Stuck on packages
Download Code
Re^7: Stuck on packages
by shigetsu (Hermit) on Jan 04, 2007 at 10:09 UTC
    You need to dereference the array reference returned by get_as_array() by saying @{$foo->get_as_array} before you print it.
Re^7: Stuck on packages
by blazar (Canon) on Jan 04, 2007 at 21:07 UTC
    ARRAY(0x18012b8) is the output.

    Which was expected. Indeed in the post you're replying to, but failed to quote properly, there was clearly written "If you dump the return of this, you'll see it's in an array."

    Just use (e.g.) Data::Dumper's Dump instead of print.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://592897]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2014-09-18 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (121 votes), past polls