Marshall has asked for the wisdom of the Perl Monks concerning the following question:
FILE:test.pl
FILE: Appointment.pm#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Appointment; my $x = Appointment->new(Month=>45, Day => 1); print "Month: ",$x->Month,"\n"; print Dumper $x; __END__ Prints: Month: 45 $VAR1 = bless( { 'Day' => 1, 'Month' => 45, 'Freq' => 'OneTime' }, 'Appointment' );
Update: I have found the replies by kevbot++ and Your Mother++ to be extremely helpful. Thanks!#!/usr/bin/perl #file: Appointment.pm package Appointment; use Moose; # automatically turns on strict and warnings my @freq_valid = (qw/OneTime Daily Monthly Quarterly/); has 'Month' => ( is => 'ro', isa => 'Int', required => 1, ); has 'Day' => ( is => 'ro', isa => 'Int', required => 1, ); has 'Freq' => ( is => 'ro', isa => 'Str', default => 'OneTime', ); 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose: checking parms in object construction
by Your Mother (Archbishop) on Aug 02, 2017 at 05:01 UTC | |
|
Re: Moose: checking parms in object construction
by kevbot (Vicar) on Aug 02, 2017 at 04:28 UTC |