Re: Help - Rookie question on Arrays

2001-05-22 Thread a p
gt;From: Paul <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED], [EMAIL PROTECTED] >CC: Aaron Craig <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >Subject: Re: Help - Rookie question on Arrays >Date: Fri, 18 May 2001 09:07:51 -0700 (PDT) > > >--- Jeff Piny

Re: Help - Rookie question on Arrays

2001-05-18 Thread Paul
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote: > On May 18, Paul said: > > @hits = grep /^$TEST1$/, @HOLDER; > > Do not use a regular expression to check for equality. It breaks far > too often. > > @equal = grep $_ eq $wanted, @original; agreed. Thanks again, Jeff. In trying to keep it simple,

Re: Help - Rookie question on Arrays

2001-05-18 Thread Jeff Pinyan
On May 18, Paul said: > @hits = grep /^$TEST1$/, @HOLDER; Do not use a regular expression to check for equality. It breaks far too often. * the $ anchor does not match the end of the string -- it matches the end of a string OR before a newline at the end of a string * if $TEST1 has any

Re:[OT]Help - Rookie question on Arrays

2001-05-18 Thread Paul
And I thought you were a raw newbie. lol! Sorry. Just trying to be explicit. ;o] --- Aaron Craig <[EMAIL PROTECTED]> wrote: > I've answered my own question: > > my $ID = "020"; > > my $rh1 = {id => 1, value => "020", name => "one"}; > my $rh2 = {id => 2, value => "040", name => "two"}; > my $r

Re: Help - Rookie question on Arrays

2001-05-18 Thread Paul
--- Aaron Craig <[EMAIL PROTECTED]> wrote: > Your example is wonderfully concise -- is there any way that you can > expand on this to get more information out of the test, ie which > member of the array matches, or returning the member if this were > in a function? Yes. ...oh, you mean you wan

Re: Help - Rookie question on Arrays

2001-05-18 Thread Aaron Craig
I've answered my own question: my $ID = "020"; my $rh1 = {id => 1, value => "020", name => "one"}; my $rh2 = {id => 2, value => "040", name => "two"}; my $rh3 = {id => 3, value => "034", name => "three"}; my $rh4 = {id => 4, value => "056", name => "four"}; my $rh5 = {id => 5, value => "030", na

Re: Help - Rookie question on Arrays

2001-05-18 Thread Aaron Craig
I haven't really played with grep at all, except for doing the standard stuff on dirs. Your example is wonderfully concise -- is there any way that you can expand on this to get more information out of the test, ie which member of the array matches, or returning the member if this were in a fu

Re: Help - Rookie question on Arrays

2001-05-17 Thread Brett W. McCoy
> How can I find out if an array contains a particular element stored in a > certain variable ? > > eg variable TEST1 = "030" > > array HOLDER = "020 040 034 056 030" > > I need to find out if "030" is present in the array HOLDER You can do it a couple of ways (there's ALWAYS more than one way to

RE: Help - Rookie question on Arrays

2001-05-17 Thread Wagner-David
1, '056', 1, '030', 1); if ( defined $Holder{$TEST1} ) { # found, so do something }else { # not found do something } -Original Message- From: a p [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 17, 2001 12:56 To: [EMAIL PROTECTED] Subject: Help - Rookie question

Re: Help - Rookie question on Arrays

2001-05-17 Thread Paul
--- a p <[EMAIL PROTECTED]> wrote: > Hi, Hi. =o) > Today is my first day on Perl so please bear with me if this sounds > stupid... lol -- welcome aboard, and don't worry about it. Just be sure to do this: perldoc -t perl >tmp and then look at tmp to see the things you can look at in more

Re: Help - Rookie question on Arrays

2001-05-17 Thread Peter Cline
Perl has a foreach loop that is very apt at doing what you want. i.e. #!/usr/local/bin/perl5 $test1 = "030"; @holder = qw(020 040 034 056 030); foreach (@holder) { $test = true if ($_ == $test1); } This loop cycles through each element of the array, temporarily housing it in the special

Help - Rookie question on Arrays

2001-05-17 Thread a p
Hi, Today is my first day on Perl so please bear with me if this sounds stupid... How can I find out if an array contains a particular element stored in a certain variable ? eg variable TEST1 = "030" array HOLDER = "020 040 034 056 030" I need to find out if "030" is present in the array HO