RE: How to get the numeric index of a element in an array

2005-05-16 Thread Charles K. Clarkson
Frank wrote: : The results given like this, it seems the loop works only for one time : : >common_white : paper : >milk_white : milk This is what you asked perl to do. Let's walk the script. First time through $item is ">blue". Since $after_white tests fal

Re: How to get the numeric index of a element in an array

2005-05-16 Thread Frank
Thanks! Mr. Clarkson's program really works. but because my array (data) is more complex. So I made an adjustment but it did not work very well. BTW: John W. Krahn suggested I can change Input Record Separator, it does work and help me to solve the problem! But I just wonder why the foll

Re: How to get the numeric index of a element in an array

2005-05-16 Thread Ing. Branislav Gerzo
Frank [F], on Monday, May 16, 2005 at 21:34 (+0800) wrote the following: F> How to determin whether I reach the end of file in Perl program? Also F> , can you tell me where I can get these informations . I scan the F> "programing perl " by Larry Wall, But it is diffculty to find what I F> wa

Re: How to get the numeric index of a element in an array

2005-05-16 Thread Frank
Hi, thanks all! I have solve my problem. But I have another question now, How to determin whether I reach the end of file in Perl program? Also , can you tell me where I can get these informations . I scan the "programing perl " by Larry Wall, But it is diffculty to find what I want f

RE: How to get the numeric index of a element in an array

2005-05-15 Thread Charles K. Clarkson
Frank wrote: : Thanks Octavian, I do need analyze element by element. but the : problem for me is like this : : my @array = ( : ">blue" : "sky" : "skirt" : "sea" : ">white" : "paper" : "flower" : ">red" : "face" : "flower" : ">green" : "grand" : "tree" : ) : : Say,

Re: How to get the numeric index of a element in an array

2005-05-15 Thread bright true
hello , you can do something like the following my $counter = -1; foreach (@array){ $counter++; if($_ =~m/$word/){ print "Element ID is $counter";} } On 5/15/05, Frank <[EMAIL PROTECTED]> wrote: > > Ing. Branislav Gerzo wrote: > > >Frank [F], on Sunday, May 15, 2005 at 19:45 (+0800) typed

Re: How to get the numeric index of a element in an array

2005-05-15 Thread Chris Devers
On Sun, 15 May 2005, Frank wrote: > If i know the element of array, can I get the numeric index of this > element? In general, you'd have to write code to "walk" through the array, then make a note of the index when you get the value you want. Something like this might do what you're asking for

Re: How to get the numeric index of a element in an array

2005-05-15 Thread Frank
nt, in order to be able to find if that array contains dupplicates and if you will find dupplicates, you might need to return a list of indexes. foreach(@array) { if ($_ eq 'blue') { #do something } } Teddy - Original Message - From: "Frank" <[EMAIL PROTECTED]>

Re: How to get the numeric index of a element in an array

2005-05-15 Thread Octavian Rasnita
<[EMAIL PROTECTED]> To: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]> Cc: Sent: Sunday, May 15, 2005 6:34 PM Subject: Re: How to get the numeric index of a element in an array > Ing. Branislav Gerzo wrote: > > >Frank [F], on Sunday, May 15, 2005 at 19:45 (+0800) typ

Re: How to get the numeric index of a element in an array

2005-05-15 Thread Frank
Ing. Branislav Gerzo wrote: Frank [F], on Sunday, May 15, 2005 at 19:45 (+0800) typed: F> If i know the element of array, can I get the numeric index of this F> element? Exist a way, but it is better using hash. In arrays you have to iterate over every element. ~~~Pls tell me the way. possi

Re: How to get the numeric index of a element in an array

2005-05-15 Thread Ing. Branislav Gerzo
Frank [F], on Sunday, May 15, 2005 at 19:45 (+0800) typed: F> If i know the element of array, can I get the numeric index of this F> element? Exist a way, but it is better using hash. In arrays you have to iterate over every element. -- ...m8s, cu l8r, Brano. [Thank goodness for my twit fil

How to get the numeric index of a element in an array

2005-05-15 Thread Frank
Hi, all If i know the element of array, can I get the numeric index of this element? Thanks Frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]