Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6670485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:16:30+00:00 2026-05-26T03:16:30+00:00

Puppy meta data gets read in from config file using (General::Config) and creates this

  • 0

Puppy meta data gets read in from config file using (General::Config) and creates this hash of hashes

$puppy_hashes = {
 puppy_blue => { name => 'charlie', age => 4 },
 puppy_red  => { name => 'sam', age => 9 },
 puppy_yellow  => { name => 'jerry', age => 2 },
 puppy_green  => { name => 'phil', age => 5 },
}

the MotherDogRobot package consumes the puppies hash to birth an array of puppy objects (lol)

package MotherDogRobot;  
use Moose;
use Puppy;
use Data::Dumper;
#moose includes warn and strict

sub init_puppy{
  my($self,%options) = @_;
  my $puppy = Puppy->new( %options );
  return ($puppy);
}

sub birth_puppies{
  my($self,$puppy_hashes) = @_;
  my @keys = keys %{$puppy_hashes};
  my @puppies = map { $self->init_puppy( $puppy_hashes->{$_} ) } @keys;
  return(@puppies);
}

sub show_me_new_puppies{
  my($self,$puppy_hashes) @_;
  print Dumper($self->birth_puppies($puppy_hashes));
}

Error odd number of arguments

passing %options to Puppy->new(%options)

no luck birthing puppies — which means I can’t put lasers on their heads =/

UPDATE

I think the problem is that I’m passing a Hash Ref to init_puppy() instead of an array or hash, so when I try to pass %options to the new constructor, it’s not getting a proper ( key => value) pair — hence the odd number of arguments error.

But from this standpoint I’ve been looking at this code too long I cant figure out how to dereference this properly.

btw this is my official day 22 of using Perl!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:16:30+00:00Added an answer on May 26, 2026 at 3:16 am

    you’re using empty variables as if they’re not empty, that is, you’re not doing anything at all

    print "hi $_ " for my @foo;
    

    This assumes that the incomplete snippet you’ve shown is what you’re really using

    update: Similarly in sub init_puppy, you never initialize my($self,%options)=@_;

    #!/usr/bin/perl --
    use strict;
    use warnings;
    Main( @ARGV );
    exit( 0 );
    sub Main {
        my $puppy_hashes = {
            puppy_blue   => { name => 'charlie', age => 4 },
            puppy_red    => { name => 'sam',     age => 9 },
            puppy_yellow => { name => 'jerry',   age => 2 },
            puppy_green  => { name => 'phil',    age => 5 },
        };
    
        for my $puppy ( MotherDogRobot->birth_puppies($puppy_hashes) ) {
            print join ' ', $puppy, $puppy->name, $puppy->age, $puppy->dump, "\n";
        }
    }
    
    BEGIN {
        package Puppy;
        BEGIN { $INC{'Puppy.pm'} = __FILE__; }
        use Any::Moose;
        has 'name' => ( is => 'rw', isa => 'Str' );
        has 'age'  => ( is => 'rw', isa => 'Int' );
    
        package MotherDogRobot;
        BEGIN { $INC{'MotherDogRobot.pm'} = __FILE__; }
        use Moose;
        use Puppy;
    
        sub init_puppy {
            my ( $self, %options ) = @_;
            my $puppy = Puppy->new(%options);
            return ($puppy);
        }
    
        sub birth_puppies {
            my ( $self, $puppy_hashes ) = @_;
            my @puppies = map { $self->init_puppy( %{$_} ) } values %$puppy_hashes;
            return (@puppies);
        }
        no Moose;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FileAttributes attrs = File.GetAttributes( path); File.SetAttributes( path, FileAttributes.Hidden ); attrs = File.GetAttributes( path); This
I would like to open 10,000 files with file names starting from abc25000 until
Has anyone successfully done this? My idea is to post to a servlet and
My models file works just fine. As soon as I replace every models.Model with
I'm playing around with the flash Video cam and I'm a real puppy-dog-level newbie
So, folks, I have this self crafted pattern that works. After some hours (I
I have the current script included below that goes into a file with extension
Trying to implement the following structure from c to use NSArray in objective-c: In
I'm building a web application using the ASP.net Membership Provider to manage, Authentication/Authorisation. I've
from sys import exit from random import randint class Map(object): def death(): print quips[randint

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.