Re: anonymous array for loop

2013-03-10 Thread Brandon McCaig
On Sun, Mar 10, 2013 at 11:06:14AM -0400, Brandon McCaig wrote: > There is no array here. There are only lists. See perldoc > perldata. > > > List value constructors > > List values are denoted by separating individual values > > by commas (and enclosing the list in parentheses where

Re: anonymous array for loop

2013-03-10 Thread Brandon McCaig
semantics). Thus, in your example above you passed split /PATTERN/ and /EXPR/ (split is built-in and its semantics are not the same as user-defined functions), and in exchange split returned a list of ('a', 'b', 'c'), which your for-loop then iterated over. At no poin

Re: anonymous array for loop

2013-03-09 Thread Brandon McCaig
On Sat, Mar 09, 2013 at 08:19:43PM -0600, Chris Stinemetz wrote: > I don't think that is true. > > Example being: > > #!/usr/bin/perl > use warnings; > use strict; > > use Data::Dumper; > > my $firstVar = "One"; > my $secondVar = "Two"; > > my @array; > push @array,[$firstVar, $secondVar]; >

Re: anonymous array for loop

2013-03-09 Thread Chris Stinemetz
On Sat, Mar 9, 2013 at 2:57 PM, Brandon McCaig wrote: > On Sat, Mar 09, 2013 at 07:24:37AM -0600, Chris Stinemetz wrote: > > Each anonymous array @files and @newFiles has 5 total elements. > > Just to nitpick, @files and @newFiles are not anonymous arrays. > They are just arrays. They have names.

Re: anonymous array for loop

2013-03-09 Thread Brandon McCaig
On Sat, Mar 09, 2013 at 07:24:37AM -0600, Chris Stinemetz wrote: > Each anonymous array @files and @newFiles has 5 total elements. Just to nitpick, @files and @newFiles are not anonymous arrays. They are just arrays. They have names. You cannot have anonymous arrays in Perl except by reference. Th

Re: anonymous array for loop

2013-03-09 Thread *Shaji Kalidasan*
------ Your talent is God's gift to you. What you do with it is your gift back to God. --- From: Chris Stinemetz To

Re: anonymous array for loop

2013-03-09 Thread Chris Stinemetz
Never mind, I got it. I was over thinking it. I just created one anonymous array with the elements I wanted then used the following loop. foreach my $file (@files) { print join( "\t", @$file[0], @$file[1] ), "\n"; $ftp->put(@$file[0], @$file[1]) || die "can't put files: @$file[0] \t @$file[1

anonymous array for loop

2013-03-09 Thread Chris Stinemetz
Thank you in advance. Each anonymous array @files and @newFiles has 5 total elements. How can I alter this nested for so that just the unique elements are printed instead of each element twice? foreach my $file (@files) { foreach my $newFileName ( @newFiles ) { print join( "\t", @$file, @$ne

Re: Incrementing letters in for loop

2010-04-15 Thread C.DeRykus
nt would be 'za' which is 'longer' > > than the final value specified'; whereas, 'yz' isn't: > > Actually, no.  "z" is in the sequence, so it stops there. > > Try: > > for ( 'u' .. ' ' ){ >    print "$_ "

Re: Incrementing letters in for loop

2010-04-14 Thread Shawn H Corey
C.DeRykus wrote: And, here's the doozy for me as I tried remembering: If the final value specified is not in the sequence that the magical increment would produce, the sequence continues until the next value is longer than the final value specified.

Re: Incrementing letters in for loop

2010-04-13 Thread C.DeRykus
On Apr 13, 8:54 am, shawnhco...@gmail.com (Shawn H Corey) wrote: > C.DeRykus wrote: > > Clear as mud?  Did you say 'Hell, no'...?  Go then and > > meditate on  autoincrement magic,  grasshopper. When > > enlightenment comes, please report back and  explain it > > to us too... > > Actually, it is be

Re: Incrementing letters in for loop

2010-04-13 Thread Brandon McCaig
2010/4/13 Magne Sandøy : > Thanks for all the good info. I think I have a grasp on incrementing and > comparison, but now, what puzzles me, is the fact that when I use "le" less > than or equal, why does it actually increment the "z"? It is by then passed > the less than, and already at equal to "z

Re: Incrementing letters in for loop

2010-04-13 Thread Magne Sandøy
Shawn H Corey wrote: Owen wrote: On Tue, 13 Apr 2010 05:35:51 +0200 Magne Sandøy wrote: Hi. I'm new to perl, and I stumbled across a strange behavior in my for loop. In the following code, the second for loop actually counts way passed what I expected, and actually stops at "yz&q

Re: Incrementing letters in for loop

2010-04-13 Thread Shawn H Corey
C.DeRykus wrote: Clear as mud? Did you say 'Hell, no'...? Go then and meditate on autoincrement magic, grasshopper. When enlightenment comes, please report back and explain it to us too... Actually, it is because string-comparison operators order strings differently than auto-increment.

Re: Incrementing letters in for loop

2010-04-13 Thread C.DeRykus
On Apr 12, 8:35 pm, msan...@gmail.com (Magne Sandøy) wrote: > Hi. > > I'm new to perl, and I stumbled across a strange behavior in my for loop. > In the following code, the second for loop actually counts way passed > what I expected, and actually stops at "yz" and n

Re: Incrementing letters in for loop

2010-04-13 Thread Shawn H Corey
Owen wrote: On Tue, 13 Apr 2010 05:35:51 +0200 Magne Sandøy wrote: Hi. I'm new to perl, and I stumbled across a strange behavior in my for loop. In the following code, the second for loop actually counts way passed what I expected, and actually stops at "yz" and not "z&qu

Re: Incrementing letters in for loop

2010-04-13 Thread Shlomi Fish
On Tuesday 13 Apr 2010 11:17:12 Magne Sandøy wrote: [SNIP] > > Hi again. > > Does this mean this is a bug? It's not a bug - this is how it works. > My point is to get "z" at the end. Using "eq" or lt" wont work. You need to evaluate the condition at the end of the loop instead of at the begin

Re: Incrementing letters in for loop

2010-04-13 Thread Magne Sandøy
Shlomi Fish wrote: Hi Magne, On Tuesday 13 Apr 2010 10:37:15 Magne Sandøy wrote: Shlomi Fish wrote: Hi Magne, On Tuesday 13 Apr 2010 06:35:51 Magne Sandøy wrote: Hi. I'm new to perl, and I stumbled across a strange behavior in my for loop. In the following code, the s

Re: Incrementing letters in for loop

2010-04-13 Thread Shlomi Fish
Hi Magne, On Tuesday 13 Apr 2010 10:37:15 Magne Sandøy wrote: > Shlomi Fish wrote: > > Hi Magne, > > > > On Tuesday 13 Apr 2010 06:35:51 Magne Sandøy wrote: > >> Hi. > >> > >> I'm new to perl, and I stumbled across a strange behavior in my

Re: Incrementing letters in for loop

2010-04-13 Thread Magne Sandøy
Shlomi Fish wrote: Hi Magne, On Tuesday 13 Apr 2010 06:35:51 Magne Sandøy wrote: Hi. I'm new to perl, and I stumbled across a strange behavior in my for loop. In the following code, the second for loop actually counts way passed what I expected, and actually stops at "yz"

Re: Incrementing letters in for loop

2010-04-12 Thread Shlomi Fish
Hi Magne, On Tuesday 13 Apr 2010 06:35:51 Magne Sandøy wrote: > Hi. > > I'm new to perl, and I stumbled across a strange behavior in my for loop. > In the following code, the second for loop actually counts way passed > what I expected, and actually stops at "yz"

Re: Incrementing letters in for loop

2010-04-12 Thread Owen
On Tue, 13 Apr 2010 05:35:51 +0200 Magne Sandøy wrote: > Hi. > > I'm new to perl, and I stumbled across a strange behavior in my for > loop. In the following code, the second for loop actually counts way > passed what I expected, and actually stops at "yz" and not

Incrementing letters in for loop

2010-04-12 Thread Magne Sandøy
Hi. I'm new to perl, and I stumbled across a strange behavior in my for loop. In the following code, the second for loop actually counts way passed what I expected, and actually stops at "yz" and not "z" as expected. As shown by the third for loop, incrementing the l

Re: for loop

2009-11-27 Thread Shawn H Corey
PigInACage wrote: > Hello all. > > I've got a file CSV with 3 column > name,surname,group > > if one of the column has got a space like > Davide,Super Dooper,Group > I cannot use it in a for loop > > for i in `cat list.csv` ; do echo $i ; done > the r

Re: for loop

2009-11-27 Thread lan messerschmidt
On Fri, Nov 27, 2009 at 6:32 PM, PigInACage wrote: > Hello all. > > I've got a file CSV with 3 column > name,surname,group > > if one of the column has got a space like > Davide,Super Dooper,Group > I cannot use it in a for loop > > for i in `cat list.csv`

Re: for loop

2009-11-27 Thread Steve Bertrand
PigInACage wrote: > Hello all. > > I've got a file CSV with 3 column > name,surname,group > > if one of the column has got a space like > Davide,Super Dooper,Group > I cannot use it in a for loop > > for i in `cat list.csv` ; do echo $i ; done > the r

for loop

2009-11-27 Thread PigInACage
Hello all. I've got a file CSV with 3 column name,surname,group if one of the column has got a space like Davide,Super Dooper,Group I cannot use it in a for loop for i in `cat list.csv` ; do echo $i ; done the result is Davide,Super Dooper,Group how can I have all inone line? Really t

Re: Variable in for loop is not automatically local?

2009-05-04 Thread Gunnar Hjalmarsson
Bryan Harris wrote: Note that the foreach variable is an alias to the loop list so modifying the variable also modifies the list elements. Out of curiosity, is it possible to manually create aliases like this as well? e.g. to make $x an alias to $y? I do not know the exact answer to your que

Re: Variable in for loop is not automatically local?

2009-05-04 Thread Bryan Harris
[lots of stuff cut out] > Note that the foreach variable is an alias to the loop list so modifying > the variable also modifies the list elements. Out of curiosity, is it possible to manually create aliases like this as well? e.g. to make $x an alias to $y? - B -- To unsubscribe, e-mail: b

Re: Variable in for loop is not automatically local?

2009-05-02 Thread John W. Krahn
Kelly Jones wrote: If I do a for loop in a subroutine, do I have to declare it private with my()? I always though for() did that for me, but I ran into a bug where code like this: sub foo {for $i (1..2) {print $i;}} affected my global $i (I think). Or was I imagining it? The variable in a

Re: Variable in for loop is not automatically local?

2009-05-02 Thread Gunnar Hjalmarsson
Kelly Jones wrote: If I do a for loop in a subroutine, do I have to declare it private with my()? I always though for() did that for me, but I ran into a bug where code like this: sub foo {for $i (1..2) {print $i;}} affected my global $i (I think). Or was I imagining it? Probably, since $i

Variable in for loop is not automatically local?

2009-05-02 Thread Kelly Jones
If I do a for loop in a subroutine, do I have to declare it private with my()? I always though for() did that for me, but I ran into a bug where code like this: sub foo {for $i (1..2) {print $i;}} affected my global $i (I think). Or was I imagining it? -- We're just a Bunch Of Regular Gu

Re: converting while loop to a for loop

2008-12-01 Thread John W. Krahn
e loop does what i'm after #my $pos = -1; #while(1) { #$pos = index($string, $subString, $pos + 1); # find next position #print "\nPOS: $pos\n"; #last if $pos == -1; # index returns -1 if substring has no match #push @indexes, $pos; #} # Wanted to convert it to a for

Re: converting while loop to a for loop

2008-12-01 Thread Rob Dixon
dippa wrote: > > Trying to work out why: > 1. the for loop does not work, want the same logic as the while loop > 2. for(my $pos = -1; $pos == -1; $pos++) only iterates through once > 3. for(my $pos = 0; $pos == -1; $pos++) does not enter loop at all Because in both cases your

converting while loop to a for loop

2008-12-01 Thread dippa
x27;m after #my $pos = -1; #while(1) { #$pos = index($string, $subString, $pos + 1); # find next position #print "\nPOS: $pos\n"; #last if $pos == -1; # index returns -1 if substring has no match #push @indexes, $pos; #} # Wanted to convert it to a for loop for learni

Re: duration of iterations of a for-loop

2007-12-21 Thread Tom Phoenix
On Dec 21, 2007 3:49 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want to determine the duration of the single iterations of > a for-loop i.e. after each iteration the duration should > be printed out. Is there a function for this implemented or > must this be done with

Re: duration of iterations of a for-loop

2007-12-21 Thread John W . Krahn
On Friday 21 December 2007 03:49, [EMAIL PROTECTED] wrote: > > Hello, Hello, > I want to determine the duration of the single iterations of > a for-loop i.e. after each iteration the duration should > be printed out. Is there a function for this implemented or > must thi

duration of iterations of a for-loop

2007-12-21 Thread [EMAIL PROTECTED]
Hello, I want to determine the duration of the single iterations of a for-loop i.e. after each iteration the duration should be printed out. Is there a function for this implemented or must this be done with the difference of two times derived from localtime? Thank you very much! Guenter

Re: For Loop error: Missing $ on loop variable at time.pl line 7.

2007-07-10 Thread Dr.Ruud
Gowtham schreef: > Martin Barth: >>> for my ($index = 0; $index <= 10; $index++) { >>>print ("$hour:$min:$sec\n"); >>> } >> >> for my $index (0..10){ >> print ("$hour:$min:$sec\n"); >> } > > Don't wrap the entire loop initializer, condition and > counter update in my(). [...] Gowtham,

Re: For Loop error: Missing $ on loop variable at time.pl line 7.

2007-07-10 Thread Gowtham
On Jul 10, 9:13 pm, [EMAIL PROTECTED] (Martin Barth) wrote: > > for my ($index = 0; $index <= 10; $index++) { > > > print ("$hour:$min:$sec\n"); > > > } > > for my $index (0..10){ > print ("$hour:$min:$sec\n"); > > } > > hth Don't wrap the entire loop initializer, condition and counter upd

Re: For Loop error: Missing $ on loop variable at time.pl line 7.

2007-07-10 Thread Mr. Shawn H. Corey
CM Analyst wrote: for my ($index = 0; $index <= 10; $index++) { for (my $index = 0; $index <= 10; $index ++ ) { --- Shawn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: For Loop error: Missing $ on loop variable at time.pl line 7.

2007-07-10 Thread Martin Barth
> for my ($index = 0; $index <= 10; $index++) { > > print ("$hour:$min:$sec\n"); > > } for my $index (0..10){ print ("$hour:$min:$sec\n"); } hth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

For Loop error: Missing $ on loop variable at time.pl line 7.

2007-07-10 Thread CM Analyst
Hello. I have this code that works fine without the for loop but fails with it with this error message: "Missing $ on loop variable at time.pl line 7." Here's the code itself: ### use strict; use warnings; use Time::Local; my ($sec, $min, $hour, $mday, $mon, $yea

Re: MySQL in a for loop

2005-07-28 Thread David Van Ginneken
essageID (90){ > : print $messageID . "\n"; > : } > : It outputs nothing.. > > Actually, it outputs "90\n". There is no reason why > the list in a 'for' loop cannot iterate over just one item. > In fact, it can make testing easier by allowing us t

RE: MySQL in a for loop

2005-07-27 Thread Charles K. Clarkson
ot;90\n". There is no reason why the list in a 'for' loop cannot iterate over just one item. In fact, it can make testing easier by allowing us to substitute a list with just one test item. foreach my $item ( @very_large_array ) { print "$item\n"; } Can be rep

Re: MySQL in a for loop

2005-07-27 Thread David Van Ginneken
Few things that I can see. I'm sure others will give you more ideas. On 7/27/05, David Foley <[EMAIL PROTECTED]> wrote: > Hi Guys, >Can you please look at the below script. The SQL query > works on it's own in separate script. But not when it is put into

MySQL in a for loop

2005-07-27 Thread David Foley
Hi Guys, Can you please look at the below script. The SQL query works on it's own in separate script. But not when it is put into the "for" loop in this script . Any ideas??

Using 'last' in for loop, and putting subst-regex within an 'if'

2004-05-10 Thread Matthew Miller
Hello. I've been hacking on Erik Oliver's rather nice setext-to-html script, refining it beyond the original interpretations of setext back in 2002. I've run into two major snags that my limited knowledge of Perl is not allowing me to get past. I'd appreciate any pointers or assistance anyone ca

Re: getting array index inside for loop

2004-04-14 Thread Andrew Gaffney
JupiterHost.Net wrote: Andrew Gaffney wrote: Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I have code that uses a 'foreach(@array) {}' to loop : through an array. I now need to be able to get the : array index inside of that. I know I could switch to : a 'for($loopva

Re: getting array index inside for loop

2004-04-14 Thread JupiterHost.Net
Andrew Gaffney wrote: Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I have code that uses a 'foreach(@array) {}' to loop : through an array. I now need to be able to get the : array index inside of that. I know I could switch to : a 'for($loopvar=0;$loopvar<@array;$lo

Re: getting array index inside for loop

2004-04-14 Thread Andrew Gaffney
Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I have code that uses a 'foreach(@array) {}' to loop : through an array. I now need to be able to get the : array index inside of that. I know I could switch to : a 'for($loopvar=0;$loopvar<@array;$loopvar++) {}' to : do that

Re: getting array index inside for loop

2004-04-14 Thread JupiterHost.Net
I have code that uses a 'foreach(@array) {}' to loop through an array. I now need to be able to get the array index inside of that. I know I could switch to a 'for($loopvar=0;$loopvar<@array;$loopvar++) {}' to do that, but I'd have to change some other code also. If not that way, is there a way

RE: getting array index inside for loop

2004-04-13 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I have code that uses a 'foreach(@array) {}' to loop : through an array. I now need to be able to get the : array index inside of that. I know I could switch to : a 'for($loopvar=0;$loopvar<@array;$loopvar++) {}' to : do that, but I'd have to change so

getting array index inside for loop

2004-04-13 Thread Andrew Gaffney
I have code that uses a 'foreach(@array) {}' to loop through an array. I now need to be able to get the array index inside of that. I know I could switch to a 'for($loopvar=0;$loopvar<@array;$loopvar++) {}' to do that, but I'd have to change some other code also. If not that way, is there a way

RE: for loop not ending

2004-01-19 Thread Hanson, Rob
u can use $max_days_old=67). Rob -Original Message- From: Damian Scott [mailto:[EMAIL PROTECTED] Sent: Monday, January 19, 2004 8:48 PM To: [EMAIL PROTECTED] Subject: for loop not ending Ok. Here's my situation. I am modifying a Perl script that was created some time ago and am

for loop not ending

2004-01-19 Thread Damian Scott
Ok. Here's my situation. I am modifying a Perl script that was created some time ago and am learning Perl on kind of a "trial by fire" basis (with a couple of good books). The problem was first brought to my attention that we still had old log files greater than 60 old. The gziplog Perl scri

Re: Question on For loop usage in Perl

2003-07-13 Thread Jeff 'japhy' Pinyan
On Jul 13, Janek Schleicher said: >Hari Krishnaan wrote at Thu, 10 Jul 2003 14:03:32 -0700: > >> I was using a for loop in the following manner in one of my perl programs. >> >> for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) { The test of $j >= 0 is waste

Re: Question on For loop usage in Perl

2003-07-13 Thread Janek Schleicher
Hari Krishnaan wrote at Thu, 10 Jul 2003 14:03:32 -0700: > I was using a for loop in the following manner in one of my perl programs. > > for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) { > > # Executing statements here > } > } > 1) Is it legal in perl to

Re: Question on For loop usage in Perl

2003-07-10 Thread Jenda Krynicky
Date sent: Thu, 10 Jul 2003 14:03:32 -0700 (PDT) From: Hari Krishnaan <[EMAIL PROTECTED]> Subject:Question on For loop usage in Perl To: [EMAIL PROTECTED] > Hello all, > I was using a for loop in the following manner

Question on For loop usage in Perl

2003-07-10 Thread Hari Krishnaan
Hello all, I was using a for loop in the following manner in one of my perl programs. for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) { # Executing statements here } 1) Is it legal in perl to use the for loop as mentioned above ? 2) If so when i compile perl gives a message as f

Re: problem opening file inside for-loop

2003-06-01 Thread R. Joseph Newton
"Johnson, Shaunn" wrote: > --thanks for the reply. > > --even still, if the file already exists, > --nothing is printed inside of the file. > --it's still empty and i'm not sure > --where it's breaking down. > > --i mean, i can see that it doesn't > --even print the first line (print statement), >

Re: problem opening file inside for-loop

2003-05-30 Thread Rob Dixon
Shaunn Johnson wrote: > --Rob > > --Thanks for your script! Looks like it works like > --a champ! > > --However, I don't have a clear understanding > --as to *how* it works. Specifically, how is the > --'build regex' being applied inside the SQL? > --I mean, how is it getting IN there? > --I'm lo

RE: problem opening file inside for-loop

2003-05-30 Thread Johnson, Shaunn
--Rob --Thanks for your script! Looks like it works like --a champ! --However, I don't have a clear understanding --as to *how* it works. Specifically, how is the --'build regex' being applied inside the SQL? --I mean, how is it getting IN there? --I'm looking at it and I don't fully grok the

Re: problem opening file inside for-loop

2003-05-29 Thread John W. Krahn
Rob Dixon wrote: > > John W. Krahn wrote: > > > > You should show the OP how to do it in perl. :-) > > Yes, but tough to do when I can only guess what 'date' does > and I have no *nix system with me. Rob, Rob, Rob ... you mean you're still running that evil MS OS? ;-) > Thanks for filling the

Re: problem opening file inside for-loop

2003-05-29 Thread Rob Dixon
John W. Krahn wrote: > Rob Dixon wrote: > > > > Shaunn Johnson wrote: > > > > > > # create a few variables > > > my $addr='[EMAIL PROTECTED]'; > > > #my $outfile=`date +%d%b%Y`; > > > my $outfile=`date | cut -f 1 -d ' '`; > > > my $datetype=`date`; > > > my $file='/usr/local/home/joe/tmp/backup_lis

Re: problem opening file inside for-loop

2003-05-29 Thread John W. Krahn
Rob Dixon wrote: > > Shaunn Johnson wrote: > > > > # create a few variables > > my $addr='[EMAIL PROTECTED]'; > > #my $outfile=`date +%d%b%Y`; > > my $outfile=`date | cut -f 1 -d ' '`; > > my $datetype=`date`; > > my $file='/usr/local/home/joe/tmp/backup_list.txt'; > > my $matchday=`date +%a`; > >

Re: problem opening file inside for-loop

2003-05-29 Thread Rob Dixon
e the loop, or, if > I create a file outside of the for loop, nothing > is written in the file. > > What am I doing wrong? > > When I run the script as-is, I do not get an error, > but I don't get the results that I expect, either. > > If I change the script so that

RE: problem opening file inside for-loop

2003-05-29 Thread Johnson, Shaunn
x27;t know *why* it's not printing --anything and not returning an error. --any thoughts? -X -Original Message- From: WC -Sx- Jones [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 1:56 PM To: [EMAIL PROTECTED] Subject: Re: problem opening file inside for-loop On Wednesday, May 2

Re: problem opening file inside for-loop

2003-05-29 Thread WC -Sx- Jones
On Wednesday, May 28, 2003, at 12:43 PM, Johnson, Shaunn wrote: my $file='/usr/local/home/joe/tmp/backup_list.txt'; You cannot create a variable from something that does not yet exist. Try creating it first: `touch /usr/local/home/joe/tmp/backup_list.txt`; my $file='/usr/local/home/joe/tmp/ba

problem opening file inside for-loop

2003-05-29 Thread Johnson, Shaunn
Howdy: I have a script where I would like to connect to my database (PostgreSQL) and do a dump depending on what day it is. I'm having problems trying to figure out why I either can't open a file to write to it inside the loop, or, if I create a file outside of the for loop, nothing

Re: For loop aliasing AND changing an array within a loop.

2003-01-24 Thread Rob Dixon
Hi Michael. Michael Hooten wrote: > While stepping through the code I wrote, I distinctly noted that the > substitution on $_ did NOT affect the array and vice versa. If you watch carefully what Perl is doing, it aliases correctly _until_ you choose to modify the array. After this the correct val

RE: For loop aliasing AND changing an array within a loop.

2003-01-24 Thread Michael Hooten
PROTECTED] Subject: Re: For loop aliasing AND changing an array within a loop. On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote: > Zeus Odin wrote: > > I think I read somewhere that you should NOT delete array elements from > > within a loop. However, the following

Re: For loop aliasing AND changing an array within a loop.

2003-01-22 Thread John W. Krahn
Paul Johnson wrote: > > On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote: > > > > I think that you are thinking of hashes. > > From perlsyn: > > If any part of LIST is an array, "foreach" will get very > confused if you add or remove elements within the loop > body, for example

Re: For loop aliasing AND changing an array within a loop.

2003-01-22 Thread Paul Johnson
On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote: > Zeus Odin wrote: > > I think I read somewhere that you should NOT delete array elements from > > within a loop. However, the following works very well. > > I think that you are thinking of hashes. From perlsyn: If any part of LIS

Re: For loop aliasing AND changing an array within a loop.

2003-01-22 Thread John W. Krahn
Zeus Odin wrote: > > When you loop through an array > >for(@array){ ... } > > should not each array element be aliased into $_: if you change $_, you > also change the element? Yes, that is correct. > This is what I remembered. However, a problem I > just encountered shook this recollectio

For loop aliasing AND changing an array within a loop.

2003-01-22 Thread Zeus Odin
When you loop through an array for(@array){ ... } should not each array element be aliased into $_: if you change $_, you also change the element? This is what I remembered. However, a problem I just encountered shook this recollection. I think I read somewhere that you should NOT delete arra

Re: foreach v. c-style for loop was Re: Fidning the index of an array

2002-04-12 Thread Jonathan E. Paton
> >> my @array = (1 .. 100); > >> my $counter = 0; > >> > >> for (@array) { > >> print "index -> $counter element -> $_\n"; > >> $counter++; > >> } > > > > The other approach is to use a C-style for-

foreach v. c-style for loop was Re: Fidning the index of an array

2002-04-12 Thread drieux
On Thursday, April 11, 2002, at 05:09 , Jeff 'japhy' Pinyan wrote: >> my @array = (1 .. 100); >> my $counter = 0; >> >> for (@array) { >> print "index -> $counter element -> $_\n"; >> $counter++; >> } > > The oth

RE: shift inside of for loop

2002-02-21 Thread Mark Anderson
comments: the for loop looks at the first element (0), @ary gets shifted inside the loop, then the for loop looks at the second element in @ary, which is now 2, since the 0 was shifted off the front. @ary is shifted again inside and then the for loop looks at the third element remaining

shift inside of for loop

2002-02-21 Thread Luke Bakken
Hi all, I've noticed some interesting behavior when trying to shift an array that you're iterating over. For example: my @ary = (0..1000); for (@ary) { if($_ <= 1000) { shift @ary; } } print scalar @ary, "\n"; This prints 500 on my NT box with ActiveStat

RE: Grep function inside a for loop does NOT grep the values.

2002-02-20 Thread Satya_Devarakonda
McCoy" cc: "Nikola Janceski" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 02/20/2002 04:26 Subject: RE: Grep function inside

RE: Grep function inside a for loop does NOT grep the values.

2002-02-20 Thread Brett W. McCoy
On Wed, 20 Feb 2002 [EMAIL PROTECTED] wrote: > Thank you - it worked. I got my output as expected. But why is '\n' > considered so bad in perl unlike shell scripting. Why did I not get the > output with '\n'. Just curious!!! It's not considered bad, but it can mess up things when you are trying

RE: Grep function inside a for loop does NOT grep the values.

2002-02-20 Thread Satya_Devarakonda
<[EMAIL PROTECTED]> 02/20/2002 10:02 AM cc: [EMAIL PROTECTED] Subject: RE

Re: Grep function inside a for loop does grep the values.

2002-02-20 Thread Jenda Krynicky
Subject:Grep function inside a for loop does grep the values. To: [EMAIL PROTECTED] BCC to: From: [EMAIL PROTECTED] Date sent: Tue, 19 Feb 2002 17:13:00 -0500 > Can somebody help me on what is wrong in

RE: Grep function inside a for loop does NOT grep the values.

2002-02-20 Thread Nikola Janceski
;, "N015\n"); let us know how it goes. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 9:11 AM To: Nikola Janceski Cc: [EMAIL PROTECTED] Subject: RE: Grep function inside a for loop does NOT grep the values. Thanks guys,

RE: Grep function inside a for loop does NOT grep the values.

2002-02-20 Thread Satya_Devarakonda
[EMAIL PROTECTED] cc: 02/19/2002 05:28 PM Subject: RE: Grep function inside a for loop does NOT grep the

RE: Grep function inside a for loop does NOT grep the values.

2002-02-19 Thread Nikola Janceski
can you give us a snip of what's in @prv_lst @txn_log -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 5:18 PM To: [EMAIL PROTECTED] Subject: Grep function inside a for loop does NOT grep the values. Hi, I am sorry, I mea

Re: Grep function inside a for loop does grep the values.

2002-02-19 Thread Brett W. McCoy
On Tue, 19 Feb 2002 [EMAIL PROTECTED] wrote: > Can somebody help me on what is wrong in the following piece of code? > > foreach (@prv_lst) > { > $item = $_; > @list_prv = grep (/$item/, @txn_log); > print "The foll. are the Txn details for Trading Partner $item \n"; >

Grep function inside a for loop does NOT grep the values.

2002-02-19 Thread Satya_Devarakonda
Hi, I am sorry, I meant to say grep does not work inside a for loop. regards, Satya - Forwarded by Satya Devarakonda/THP on 02/19/2002 05:18 PM

Grep function inside a for loop does grep the values.

2002-02-19 Thread Satya_Devarakonda
Can somebody help me on what is wrong in the following piece of code? foreach (@prv_lst) { $item = $_; @list_prv = grep (/$item/, @txn_log); print "The foll. are the Txn details for Trading Partner $item \n"; print @list_prv; for (@txn_lst) {

Re: Generating for loop paterns HELP!

2002-02-14 Thread Bruce Ambraal
Hi Everyone had to crawl before they could walk, JON, stop being polite and help me I need your assistance now... Cheers Bruce >>> Jon Molin <[EMAIL PROTECTED]> 02/14/02 12:00PM >>> This smells homework! /jon Bruce Ambraal wrote: > > Hi > > I have done (b) for coding see below, could som

Re: Generating for loop paterns HELP!

2002-02-14 Thread Jon Molin
This smells homework! /jon Bruce Ambraal wrote: > > Hi > > I have done (b) for coding see below, could someone assist with > (a) (b) (d) > > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = ; > > for ($r = 1; $r <= $num_rows; $r++) > { > for ($i=1; $i<=

Generating for loop paterns HELP!

2002-02-14 Thread Bruce Ambraal
Hi I have done (b) for coding see below, could someone assist with (a) (b) (d) #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = ; for ($r = 1; $r <= $num_rows; $r++) { for ($i=1; $i<= $r; $i++) {print (" \n");} for ($i = $num_rows + 1 - $r;$i>=1; $i--){ pr

Generating for loop paterns HELP!

2002-02-13 Thread Bruce Ambraal
Hi I have done (b) for coding see below, could someone assist with (a) (b) (d) #!/usr/local/bin/perl -w my $num_rows; my $i; my $r; $num_rows = ; for ($r = 1; $r <= $num_rows; $r++) { for ($i=1; $i<= $r; $i++) {print (" \n");} for ($i = $num_rows + 1 - $r;$i>=1; $i--){ pr

Re: problems with a for-loop

2001-08-10 Thread Ray Barker
IL PROTECTED]> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date: August 10, 2001 8:03 AM Subject: problems with a for-loop >I'm stuck with a for-loop and would appreciate any help I can get. I hope >the code is somewhat intelligible, as it comes out of a larger script. > &g

problems with a for-loop

2001-08-09 Thread Birgit Kellner
I'm stuck with a for-loop and would appreciate any help I can get. I hope the code is somewhat intelligible, as it comes out of a larger script. The code serves to print out individual search results for a flatfile database query, called in a cgi-script. All matching records are stor

Re: For loop...

2001-06-24 Thread Brett W. McCoy
On Sun, 24 Jun 2001, Tim Grossner wrote: > I am using a for (@targets) loop to connect to cisco routers...if the > target is unreachable I need it to go on to the next target in the array > @targets. What should I look for? An "else" statement or what? You can do something like this: for(@targe

Re: For loop...

2001-06-24 Thread Jos I. Boumans
foo) { if (condition) {do stuff } } hth, Jos Boumans - Original Message - From: "Tim Grossner" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, June 24, 2001 11:13 PM Subject: For loop... > I am using a for (@targets) loop to connect to cisco routers...if

For loop...

2001-06-24 Thread Tim Grossner
I am using a for (@targets) loop to connect to cisco routers...if the target is unreachable I need it to go on to the next target in the array @targets. What should I look for? An "else" statement or what? Tim Grossner voice - 217-438-6161 pager - 217-467-3148 cell - 217-971-3060 data - [EMAIL