Hi LadyAleena,
three things that caught my attention:
- Some comments would be nice, otherwise it's hard to deduce what the individual methods are supposed to do without seeing the data and other classes you're using.
- Always use 2-argument bless, i.e. bless $ref, $class, otherwise subclassing will not work should you decide to do it later.
- The whole blessing ritual doesn't actually gain you anything here as your methods as basically all class methods that you use like glorified procedures. The point of having objects (well, one of them) is to allow for more flexibility with regard to things you have hardcoded right now like the data file name and stuff like %add_lists_data without having to specify them each time. E.g.
sub new {
my ($class, $datafile, $accounts) = @_;
return bless {
file => $datafile,
accounts => $accounts,
}, $class;
}
Then you can call methods on that object an reuse the data you passed in on new(), and e.g. cache more data in your instance data as you read them (in case you're likely to need them again later):
sub acct_data {
my ($self, $type) = @_;
die "Invalid type, $type does not exist." unless defined $headings
+{$type};
return $self->{data}{$type} if defined $self->{data};
return $self->{data}{$type} = {
get_hash(
file => data_file($self->{file}, "$type.txt"),
headings => $headings{$type},
)
}
}
-
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.
|