[ic] [if ordered] in perl?

Thomas J.M. Burton tom at globalfocusdm.com
Fri Jun 25 14:47:33 EDT 2004


Stefan Hornburg wrote:
> On Fri, 25 Jun 2004 00:57:29 +0000 (UTC)
> Jon Jensen <jon at endpoint.com> wrote:
> 
> 
>>On Thu, 24 Jun 2004, Thomas J.M. Burton wrote:
>>
>>
>>>So far, I know that I can access the cart with something like
>>>
>>>	my $cart = $Carts->{main};
>>>
>>>being still a novice with perl, I'm not sure how to search that array 
>>>for the item code that I want to check for. I'm sure it's simple, but 
>>>could someone please help me out?
>>
>>Off the top of my head, I think something like this will work:
>>
>>for (@$cart) {
>>	next unless $_->{code} eq 'some_code';
>>	# do something with item in %$_
>>}
> 
> 
> Or:
> 
> @some_codes = grep {$_->{code} eq 'some_code'} @$cart;
> 
> 	Racke
> 


Thanks to both of you! That really helped. :)

-Tom


-- 
________________________________________
Thomas J.M. Burton
Design & Production Director
Global Focus Digital Media, LLC
www.globalfocusdm.com


More information about the interchange-users mailing list