Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, So this helped but it didn't solve it. I finally played with this enough - the real answer is (tested as correct):
package Simple; use Class::MethodMaker get_set => [qw(a b)], new_with_init => 'new'; sub init { my $self = shift; my %in_args = @_; my %default_args = ( b => "default"); my %final_args = (%default_args, %in_args); foreach my $thiskey (keys(%final_args)) { $self->{$thiskey} = $final_args{$thiskey}; } return; } -------------- in use_it.pl --------- use Simple; my $test = new Simple (a=>1); # now a==1, b==default. my $test = new Simple (a=>1, b=>2); # now a==1, b==2.
I've reported the contents of this posting to the Class::MethodMaker author to request that this information be included in the readme, or a modification to the module be made so it's easier to do.

Thanks for the assistance, samtregar, you started me on the right path. I appreciate it.

Cordially, -- Kevin


In reply to Re: Class::MethodMaker initialization of default values by justanyone
in thread Class::MethodMaker initialization of default values by justanyone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found