SolaGracia has asked for the wisdom of the Perl Monks concerning the following question:

Hi Experts, I've created a package that looks like this:
package Module_IO; use Moose; has name => (is => 'rw', isa => 'Str'); has net_type => (is => 'rw', isa => 'Str'); has width => (is => 'rw', isa => 'Str'); has direction => (is => 'rw', isa => 'Str'); sub print_all_IO{ my ($self) = @_; print $self->name; }
And I have a multi-dimensional array which contains handles to objects of type "Module_IO". Each File creates a new Object for every line of input from it.
$Module_IO_container[$FileNum][$index] = $obj;
And once I have populated this array with sufficient number of handles, I want to print them out:
foreach my $a1 (@Module_IO_container) { foreach my $b1 (@$a1) { print $b1->print_all_IO, "\n"; } }
However, as a result I get: one1 two1 three1 ... instead of: one two three What am I doing wrong?

Replies are listed 'Best First'.
Re: Package printing method issue
by chromatic (Archbishop) on Jun 24, 2013 at 18:06 UTC

    You're also printing the return value of the print in print_all.

Re: Package printing method issue
by SolaGracia (Initiate) on Jun 24, 2013 at 18:20 UTC
    Got it. Thanks!