>From ur example i assume that:
my @order is an array collecting all of the objects with each order.
So, instead of
my @order = new miva_order;
we mean to say:
my @orders;
my $obj = new miva_order;
$obj->order_number(get_order_num_via_regex());
push @orders,$obj;
for (my $w=0;$w<=$#orders;$w++) {
print $order[$w]->order_number();
}
Note that in the for loop above i am starting $w with 0 and not 1. If u start with 1
and ur @order have only 1 element, it won't print anything because the index start
with '0'
-Sharad
-----Original Message-----
From: Trevor Morrison [mailto:[EMAIL PROTECTED]
Sent: Sunday, July 06, 2003 10:37 AM
To: [EMAIL PROTECTED]
Subject: Data Structures in Perl
Hi,
I am new to using data structures in Perl, but have played with them in C (a
long time ago). I have downloaded the Class::Struct::Fields module on my
W2K system and all works well. I am finding the documentation a little
terse though.
I am trying to read into my Perl program orders that was placed through an
on-line shopping cart that are sent to an Outlook mailbox. I export the
email to a file that I read into my Perl program. Since each order is
basically the same as far as content is concerned there are some variation.
I would like to use a data structure to store each orders information in.
Now, I have read through the "Programming Perl" manual (Chapter 9) on Data
structures several times and searched the web for the information that I
need, but cannot find it.
If I claim my data structure like so:
use Class::Struct::FIELDS;
struct (miva_order => {
order_number =>'$' ,
date =>'$' ,
bill_name =>'$' ,
ship_name =>'$' ,
ship_email_address =>'$' ,
ship_phone_number =>'$' ,
ship_business_name =>'$' ,
ship_to_street =>'$' ,
ship_to_city =>'$' ,
ship_to_state =>'$' ,
ship_to_zip =>'$' ,
bill_to_street =>'$' ,
bill_to_city =>'$' ,
bill_to_state =>'$' ,
bill_to_zip =>'$' ,
quantity =>'$' ,
code =>'$' ,
shipping_method =>'$' ,
shipping_amount =>'$' ,
sales_tax =>'$' ,
notes =>'$'
}
);
my @order = new miva_order;
I want to fill the fields saying $order->order_number($order_numb) where the
$orders numb is pulled from the email using regular expressions.
Now, what I want to be able to do is say :
for (my $w=1; $w<=$number_of_orders; w++) {
print $order[$w]->order_number ;
}
and have all the order numbers that are associated with the each of the
orders print out; and it does not work this way. This is where my problem
is, I am coding wrong and I cannot see it. Any help is appreciated.
Trevor
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]