Rob Dixon wrote:
> Mathew Snyder wrote:
>> It looks like an object is what I want.  Am I correct?  Suppose I need
>> to work
>> with a bit of data that actually has 11 attributes.  This would be an
>> object of
>> another type.  However, I need to manipulate pieces of it
>> differently.  So I'm
>> guessing I would create an object thusly:
>>
>> sub objectname {
>>     my %hashOfAttribs {
>>     attrib1 => undef,
>>     attrib2 => undef,
>>     attrib3 => undef
>>     }
>> }
>>
>> I would then create an instance of that object
>>
>> my $instance = new objectname();
>>
>> I'm not certain though, how to populate the elements.  would it
>> actually be
>> my $instance = new objectname(attrib1 => value, attrib2 => value,
>> attrib3 =>
>> value)?  Or would I create the instance as above and then populate it
>> by some
>> other means?  For instance
>> $instance->hashOfAttribs {
>>     attrib1 => value,
>>     attrib2 => value,
>>     attrib3 => value
>> };
>>
>> Am I at least on the right track?
> 
> Well, sort of. Objects are simply intelligent data structures -
> structures with
> code as well as data that know how to perform operations on themselves.
> So you
> still have to decide on your basic data structure first, and we still
> need to
> know more about what the data is that you're trying to represent before
> we can
> help!
> 
> What you've written above is pretty much correct expect that Perl
> classes (types
> of objects) are packages not subroutines. But first lets be sure you
> really need
> to create objects.
> 
> Rob
> 
> 
> 

I'm building reports for our work ticket system.  The tickets are
actually objects themselves.  After accessing an instance of a ticket
object one simply accesses the various attributes such as the ticket
number ($ticket->id) or the subject of the ticket ($ticket->Subject).  I
need to do more than just access these attributes and print them out though.

There are several things that need to be done with the data though:
determine which tickets have the highest priority, averaging the time
spent on each ticket, the average time spent on each customer, etc.  In
order to get the information I need I have to store the data in a hash
outside of the actual ticket object.  Once all of the data has been
processed I need to print out the information for each ticket for each
customer and user.

My superiors want the printout for each of these reports to contain all
kinds of information under several headers such as the ticket id, owner,
customer, time spent on it, when it's due for completion, etc.  Needing
up to (but not necessarily) 11 columns I would end up with a hash
dropping 10 levels deep (n-1, right?).  Eventually, those levels would
contain only one item each in turn containing one item each.  All so I
can print out as many columns as requested

As well, I'll potentially be dealing with upwards of a hundred tickets
at a time.

That's the absolute simplest way I can put it.  Let me know if it isn't
enough to work with.

Mathew
Keep up with my goings on at http://theillien.blogspot.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to