Re: Index a list

2009-07-10 Thread Steve
On Fri, 2009-07-10 at 13:13 -0700, Jim Gibson wrote: > On 7/10/09 Fri Jul 10, 2009 12:37 PM, "Steve" > scribbled: > > > Hi list memebers. I'm new here and I'm interested in learning about > > Perl. I've managed to get some programs together but have a lot to > > learn. > > > > May I put a ques

Re: Index a list

2009-07-10 Thread Jim Gibson
On 7/10/09 Fri Jul 10, 2009 12:37 PM, "Steve" scribbled: > Hi list memebers. I'm new here and I'm interested in learning about > Perl. I've managed to get some programs together but have a lot to > learn. > > May I put a question to the experts? > > Suppose I have a text file that has a whopp

Re: Index a list

2009-07-10 Thread Shawn H. Corey
On Fri, 2009-07-10 at 20:37 +0100, Steve wrote: > Hi list memebers. I'm new here and I'm interested in learning about > Perl. I've managed to get some programs together but have a lot to > learn. > > May I put a question to the experts? > > Suppose I have a text file that has a whopping amount of

Re: Index not incrementing

2008-09-20 Thread John W. Krahn
AndrewMcHorney wrote: Hello Hello, I am working on a perl script which is strictly loops for performance testing. For some reason the index for the quarterback index is not incrementing. That is because it is outside of the while loops. Also sometimes I am getting an error message about t

Re: Index not incrementing

2008-09-20 Thread Mr. Shawn H. Corey
On Sat, 2008-09-20 at 13:08 -0700, AndrewMcHorney wrote: > Hello > > I am working on a perl script which is strictly loops for performance > testing. For some reason the index for the quarterback index is not > incrementing. Also sometimes I am getting an error message about the > last right br

Re: Index not incrementing

2008-09-20 Thread Jack Gates
On Saturday 20 September 2008 04:08:20 pm AndrewMcHorney wrote: > Hello > > I am working on a perl script which is strictly loops for performance > testing. For some reason the index for the quarterback index is not > incrementing. Also sometimes I am getting an error message about the > last right

Re: Index not incrementing

2008-09-20 Thread Jack Gates
On Saturday 20 September 2008 04:08:20 pm AndrewMcHorney wrote: > $NumberQuarterbacks = 32; > $NumberRunningBacks = 60; > > $QuarterbackIndex = 0; > > while ($QuarterbackIndex < $NumberQuarterbacks) > { >      $Runningback1Index = 0; >      while ($RunningBack1Index < $NumberRunningBacks) >      {

RE: index

2003-10-01 Thread TN
riginal Message- From: Ronen Kfir [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 01, 2003 9:43 AM To: [EMAIL PROTECTED] Subject: RE: index Importance: High Sorry about the last one. I wrote some test & somehow it flipped away! The following script meant to calculate simple math dril

RE: index

2003-10-01 Thread Thomas Bätzler
Ronen Kfir asked: > The following script meant to calculate simple math drills, > such as 5 * > 9 or 4 + 3, written in one line. What I cannot comprehend is the lines > marked with ---. What do they do? Why is there a "0 < index..." That looks like somebody wrote a C p

RE: index

2003-10-01 Thread Ronen Kfir
Sorry about the last one. I wrote some test & somehow it flipped away! The following script meant to calculate simple math drills, such as 5 * 9 or 4 + 3, written in one line. What I cannot comprehend is the lines marked with ---. What do they do? Why is there a "0 < index..." Oh, it all makes

RE: index

2003-10-01 Thread Stephen Hardisty
Oh, it all makes sense now. what are you going on about man? > Hi, > > > my $line = ; > chomp $line; > > my $first_space = index($line , " "); > > my $a = substr($line, 0, $first_space); > > > > my $last_space = rindex($line , " "); > my $b = substr($line, $last_space+1); > > > >

Re: index of an array element

2001-10-03 Thread Michael Fowler
On Wed, Oct 03, 2001 at 07:09:36PM +0530, [EMAIL PROTECTED] wrote: > I am not using hashes for the same reason described by Rex, i.e.. My list might > not a key=value pair everytime. The list could be for example > ("GMM_ASSIGN_REQ", "TLLI=0x123456", "TLLI_INDEX=00", "LLC_PDU=$pdu); > > Here , th

Re: index of an array element

2001-10-03 Thread Sudarsan Raghavan
In a later mail the OP has mentioned that her list may be of the form my @ops_list = ("a", "b=7", "c=8"); The first element does not have a "=" in it. I am assuming that the key that she uses for search here is "a". Your code snippet will return an undef when called with some_func (@ops_list, "a")

RE: index of an array element

2001-10-03 Thread RArul
found } -- Rex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 9:40 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: index of an array element I am not using hashes for the same reas

RE: index of an array element

2001-10-03 Thread minid
as key value pair. Regards, -Mini. [EMAIL PROTECTED] on 10/03/2001 06:31:15 PM To: [EMAIL PROTECTED], Mini Dwivedi/HSS@HSS cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: index of an array element For key-value pair type of lists, hashes are the way to go. I had shown the other way us

Re: index of an array element

2001-10-03 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > For key-value pair type of lists, hashes are the way to go. I had shown the > other way using a list, which does not need the 'key-value' caveat. > > However for your case, Mini, you need to tread the hash path as shown by > Sudarshan. > > Here is a code snippet you can

RE: index of an array element

2001-10-03 Thread RArul
return("undef"); #WE should not get here if a match is found } } - Rex -Original Message- From: Sudarsan Raghavan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 8:59 AM To: [EMAIL PROTECTED] Cc: Rex Arul; [EMAIL PROTECTED] Subject: Re: index of an array el

Re: index of an array element

2001-10-03 Thread Sudarsan Raghavan
gt; > "Rex Arul" <[EMAIL PROTECTED]> on 10/03/2001 06:02:30 PM > > To: "Sudarsan Raghavan" <[EMAIL PROTECTED]>, Mini Dwivedi/HSS@HSS > cc: [EMAIL PROTECTED] > > Subject: Re: index of an array element > > But that would work only for key=v

Re: index of an array element

2001-10-03 Thread minid
IL PROTECTED]>, Mini Dwivedi/HSS@HSS cc: [EMAIL PROTECTED] Subject: Re: index of an array element But that would work only for key=value type of situations. If @list = (2,'a',100,'cat') then you cannot rely on Hashes because order cannot be preserved. At such instan

Re: index of an array element

2001-10-03 Thread Sudarsan Raghavan
ces, you might need to code a custom function as shown in my previous > mail. > > Right? > > -- Rex > > - Original Message - > From: "Sudarsan Raghavan" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> &g

Re: index of an array element

2001-10-03 Thread Rex Arul
l Message - From: "Sudarsan Raghavan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, October 03, 2001 8:18 AM Subject: Re: index of an array element > [EMAIL PROTECTED] wrote: > > > Hi , > > > > Say I

Re: index of an array element

2001-10-03 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi , > > Say I have an array in perl, > > @list = ("a=3", "b=5", "c=8", "d=9", "e=2", "f=0"); looking at your list a hash seems like a better option, the hash will be like %hashlist = ( a => 3, b => 5,

Re: index of an array element

2001-10-03 Thread Rex Arul
Will this be sufficient? my($array) = ['a=1', 'b=2', 'c=3', 'd=4']; my($str) = 'd=43'; my($index) = indexOf($array,$str); print ("Index of $str in the array is = $index"); sub indexOf{ my($arr) = shift; my($val) = shift; for(my $i=0; $i < @{$arr}; $i++){ return($i) if($arr->[$i] eq $val);

Re: Index of foreach

2001-09-18 Thread Andrea Holstein
"Brett W. McCoy" wrote: > > Then you can use 'for(my $i = 0; $i < @array; $i++)'. In your example > above, you are incrementing $i twice (first postincrement, then > preincrement). It doesn't make sense (to me, at least) to have an index > counter, and then still assign the array element to a t

Re: Index of foreach

2001-09-18 Thread Rasoul Hajikhani
Thanks for all the help :) "Brett W. McCoy" wrote: > > On Tue, 18 Sep 2001, Andrea Holstein wrote: > > > > On Tue, 18 Sep 2001, Andrea Holstein wrote: > > > > > > > Try > > > > for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var = > > > > $array[++$i]) { > > > >... > > > > } > > >

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
On Tue, 18 Sep 2001, Andrea Holstein wrote: > > On Tue, 18 Sep 2001, Andrea Holstein wrote: > > > > > Try > > > for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var = > > > $array[++$i]) { > > >... > > > } > > > > Good Heavens! Why would you go to all of that trouble when a simple > >

Re: Index of foreach

2001-09-17 Thread Andrea Holstein
"Brett W. McCoy" schrieb: > > On Tue, 18 Sep 2001, Andrea Holstein wrote: > > > Try > > for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var = > > $array[++$i]) { > >... > > } > > Good Heavens! Why would you go to all of that trouble when a simple > foreach will do? > You're right,

RE: Index of foreach [ot]

2001-09-17 Thread Sid Malhotra
: Re: Index of foreach Rasoul Hajikhani wrote: > > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } > > Thanks in advance.

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
On Tue, 18 Sep 2001, Andrea Holstein wrote: > Try > for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $var = > $array[++$i]) { >... > } Good Heavens! Why would you go to all of that trouble when a simple foreach will do? -- Brett http://www.ch

Re: Index of foreach

2001-09-17 Thread Andrea Holstein
Rasoul Hajikhani wrote: > > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } > > Thanks in advance. > -r Try for (my $i=0, my $var = $array[$i]; $i < @array; $i++, $

Re: Index of foreach

2001-09-17 Thread Brett W. McCoy
On Mon, 17 Sep 2001, Rasoul Hajikhani wrote: > Hi there, > is there any way to know what is the "current" index value in a foreach > loop? > > EX: > > foreach my $var (@array) > { > # need the index of the array > } Just index through the array this way: foreach my $var (0..$#array) {

Re: Index of foreach

2001-09-17 Thread P lerenard
you can run a counter inside the loop Pierre >From: Rasoul Hajikhani <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Index of foreach >Date: Mon, 17 Sep 2001 12:23:51 -0700 > >Hi there, >is there any way to know what is the "current" index value in a foreach >loop? > >EX: > >foreach my $var

RE: index inside foreach{ ..}

2001-08-15 Thread Chris Rogers
I don't know if you can do it using a foreach but I would use a for loop. It may be just a tad slower but you'll get the results you're looking for. Using the loop below will start at the last index of the array @a and loop down to the first (assuming that the first index of the array is 0). @a