"Gupta, Sharad" <[EMAIL PROTECTED]> writes:

> >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();
                   ^ 'order', or 'orders'?
> }

The Perlish way to do the above is:

foreach my $order (@orders) {
  print $order->order_number();
}

This iterates over each element in the array @orders, and places them
in turn in a variable called '$order'.  Do it this way, and you don't
have to worry about the index of the array at all.

-RN

-- 
Robin Norwood
Red Hat, Inc.

"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to