JK_Bean has asked for the wisdom of the Perl Monks concerning the following question:
sub IsItem { # usage: IsItem(item to find, pointer to list to search) my $ref = @_[1]; foreach my $e (@{$ref}) { if (@_[0] eq $e) {return 1} } return 0; } my @a = (10,20,30); print 'IsItem=',IsItem(20,\@a); print 'IsItem=',IsItem(5,\@a);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determining if an element in a list
by runrig (Abbot) on Sep 13, 2001 at 01:37 UTC | |
|
Re: Determining if an element in a list
by shadox (Priest) on Sep 13, 2001 at 01:51 UTC | |
by davorg (Chancellor) on Sep 13, 2001 at 12:39 UTC | |
|
Re: Determining if an element in a list
by jmcnamara (Monsignor) on Sep 13, 2001 at 03:16 UTC |