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

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 want

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

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

2005-05-16 Thread Charles K. Clarkson
Frank mailto:[EMAIL PROTECTED] 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 false,

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

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.

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

2005-05-15 Thread Octavian Rasnita
Hi, Let's say you have the following array: my @array = ( 'blue', 'white', 'red', 'blue', 'green', 'blue', ); And let's say you want to get the index for the 'blue' element. I guess it is obvious that you need to analyse element by element, in order to be able to find if that array contains

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

2005-05-15 Thread Frank
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, I need get all elements after white before red. Be notice, any new color begin with , so, I think I can my

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 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: F

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

2005-05-15 Thread Charles K. Clarkson
Frank mailto:[EMAIL PROTECTED] 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, I need get all elements after