very new to object oriented perl and the following already amkes my head spins... please help me understand thanks
my %default_fields =( desired_temp =>4, desired_volume=>qw[/1 2 3 4 5/], desired_mark=>100 ); my @required_fields=qw/location/; my @fields =(keys %default_fields,@required_fields); #I don't quite get what the part keys %default_fields) .. I # know it +put and expand everything into the @fields array sub new { my ($class,%args)=@_; foreach (@required_fiels) { #what does exists($args{$_}}means\? exists($args{$_}) or croak('required fieds $_ omitted"); } %args = (%default_fields,%args); #either set to defaults or new valu +es @this{@fields} = @args{@fields}; #this create a this array of array and set the contents to args return bless(\%this,$class); }

2006-03-11 Retitled by g0n, as per Monastery guidelines
Original title: 'can someone explain'


In reply to Please Explain This Constructor by edwardt_tril

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.