[ic] [if ordered] in perl?
Stefan Hornburg
racke at linuxia.de
Fri Jun 25 05:56:28 EDT 2004
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
--
Upcoming Talks and Presentations:
Linuxtag 2004, 25. Juni: Courier Mail Server (http://www.linuxtag.org/)
Perlworkshop 2004, 30. Juni: Entwicklung großer Perlanwendungen
am Beispiel von Interchange (http://www.perlworkshop.de/)
More information about the interchange-users
mailing list