I am reworking the source code and docs for Resources so that both take use of newer features of Perl/pod and so that the source does not create compiler warnings. I am doing so because the author's email bounces and the module was last updated in '97.

Not in any hurry, I applied the microscope to the new method and docs today. Here are his docs for the method:

new Resources ($resfile);

Creates a new resource database, initialized with the defaults for class Resources (see below for a list of them).

If a nonempty file name is specified in $resfile, it initializes the object with the content of the so named resource file. For safe (non overwriting) loading, see the load method below.

If the special file name "_RES_NODEFAULTS" is specified, the object is created completely empty, with not even the Resources class defaults in it.

Returns the new object, or undef in case of error.

To me, these docs were fraught with confusion. After looking at the source code, I have created the following docs:

Resources->new ( [ $resfile ] ) ;

This method is called to create a new resource database object, heretofore referred to as $res

The method behavior is based on:

  1. The method was called with $resfile
    1. The method was called with $resfile eq _RES_NODEFAULTS
    2. The method was called with $resfile ne _RES_NODEFAULTS
  2. The method was called without $resfile

In case 1.1, the object is created completely empty, with NO resources whatsoever.

In both case 1.2 and case 2, the "CORE" resources from Resources.pm are bound to the object. In case 1.2, the object is further initialized via a call to $res->load($resfile)

I am including the source code for his new method for your reference:

sub new { my $type = shift; my $resfile = shift; my ($name, $valdoc, $app); my $res = bless {}; $res->{Load} = 0; # 1 if loading $res->{Merge} = 0; # 1 if merging $res->{Wilds} = {}; # Wildcarded resources. $res->{Res} = {}; # Named resources. $res->{Owned} = {}; # Inverted index of member clases. $res->{Isa} = {}; # Inverted index of base classes. # Safe environment for the evaluation of constructors. $res->{Safe} = new Safe or ($res->_error("new", "can't get a Safe object."), return undef); # Hack hack - the special filename "_RES_NODEFAULTS" is # used to prevent resource initialization (e.g. when called by the # "bypattern" method unless ($resfile and $resfile eq "_RES_NODEFAULTS") { # Must make sure this is not overridden by a wildcard $res->{Wilds}->{'.*resources\.updates'} = [0]; $res->{Res}->{'resources.updates'}->[$Value] = 0; # Get appclass without extensions if (($app = $Resources{'resources.appclass'}->[$Value]) =~ /\./) + { $Resources{'resources.appclass'}->[$Value] = (split(/\./, $app))[ +0]; } # Bootstrap defaults. We don't want any subclassing here while (($name, $valdoc) = CORE::each(%Resources)) { $res->{Res}->{$name} = $valdoc; } } if ($resfile and $resfile ne "_RES_NODEFAULTS") { $res->load($resfile) || ($res->_error("new", "can't load"), return undef); } $res; }

DBSchema::Sample


In reply to Rewording the Resources docs by princepawn

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.