Re: foreach question

2006-10-31 Thread Rob Dixon
Andy Greenwood wrote: I have a reference to an annonymous array, which I am looping through with foreach(@$servref) { if ( checkServer($_, $dn) ) { push(@$goodservref, $_); } else { # server wasn't good. Add another item to the list push

Re: foreach question

2006-10-31 Thread Tom Phoenix
On 10/31/06, Andy Greenwood <[EMAIL PROTECTED]> wrote: I have a reference to an annonymous array, which I am looping through with foreach(@$servref) { Based on certain criteria, I want to add a new item to the end of the $servref array. Is it safe to do this inside the foreach loop? Nope;

Re: foreach question

2006-10-31 Thread lawrence
> > I have a reference to an annonymous array, which I am looping through with > > foreach(@$servref) { > if ( checkServer($_, $dn) ) { > push(@$goodservref, $_); > } else { > # server wasn't good. Add another item to the list > push

foreach question

2006-10-31 Thread Andy Greenwood
I have a reference to an annonymous array, which I am looping through with foreach(@$servref) { if ( checkServer($_, $dn) ) { push(@$goodservref, $_); } else { # server wasn't good. Add another item to the list push(@$servref, newitem);

Re: for/foreach question

2003-07-24 Thread david
"Hemant Desai" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > perl -MO=Deparse -e 'for $i (1..4){;}' > is the -MO=Deparse option explained anywhere ? yes. [panda]$ perldoc perlcompile NAME perlcompile - Introduction to the Perl Compiler-Translator DESCRIPTION Perl has alw

Re: for/foreach question

2003-07-24 Thread Steve Grazzini
On Fri, Jul 25, 2003 at 10:32:14AM +0530, Hemant Desai wrote: > perl -MO=Deparse -e 'for $i (1..4){;}' > is the -MO=Deparse option explained anywhere ? % perldoc O % perldoc B::Deparse The -M switch adds a "use Module" statement to your code. -- Steve -- To unsubscribe, e-mail: [EMAIL

RE: for/foreach question

2003-07-24 Thread Hemant Desai
perl -MO=Deparse -e 'for $i (1..4){;}' is the -MO=Deparse option explained anywhere ? -Original Message- From: david [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:34 PM To: [EMAIL PROTECTED] Subject: Re: for/foreach question Peter Fleck wrote: > I just stumb

Re: for/foreach question

2003-07-24 Thread awarsd
Hi, I think it is good to have foreach and for loop even tough they are the same if you are searching in a file you can almost make a sentence foreach $line(@infile) #<-- to me this is more readable than for $line(@infile) But for loop, I use it only for numbers for(1..53) or for( $i=0;$i<50;$i++)

Re: for/foreach question

2003-07-24 Thread david
Peter Fleck wrote: > I just stumbled upon this in some perl I'm working on: > > for $arrayref (@datedbi) { > #do stuff > } > > It didn't look right and sure enough, it should be 'foreach'. > > But it worked fine and that's my question - why is this working? > > @datedbi's elements are refe

Re: for/foreach question

2003-07-24 Thread Jeff 'japhy' Pinyan
On Jul 24, Peter Fleck said: >for $arrayref (@datedbi) { >#do stuff >} > >It didn't look right and sure enough, it should be 'foreach'. > >But it worked fine and that's my question - why is this working? In Perl, 'for' and 'foreach' are the EXACT SAME THING. for $x (@list) ... foreach $x

for/foreach question

2003-07-24 Thread Peter Fleck
I just stumbled upon this in some perl I'm working on: for $arrayref (@datedbi) { #do stuff } It didn't look right and sure enough, it should be 'foreach'. But it worked fine and that's my question - why is this working? @datedbi's elements are references to lists and they all seem to be get

RE: Foreach question

2001-11-02 Thread Richard_Cox
On 1 November 2001 22:17, shalini Raghavan [mailto:[EMAIL PROTECTED]] wrote: > Thank you for the help.I've been trying to use a script that uses the > map function in the following manner > my $var = chr(13); for the control character ^M > my @mapped = map{ > s/$var//g; >

Re: Foreach question

2001-11-01 Thread Carl Rogers
>What I'd really like to do though is to be able to write back(append) >to the same file.I am confused about opening a file in the append mode. Not sure if this is what you mean, but open (MYFILE, ">>file_to_append_to.txt") or die "Can't open $!\n"; Will open a file in the append mode Then

Foreach question

2001-11-01 Thread shalini Raghavan
Thank you for the help.I've been trying to use a script that uses the map function in the following manner my $var = chr(13); for the control character ^M my @mapped = map{ s/$var//g; s/"//g; $_; }@contents; What I'd really

RE: foreach question

2001-07-24 Thread Tom Malone
OK - that clears it up - thanks! Tom -Original Message- From: Mooney Christophe-CMOONEY1 [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 24, 2001 5:03 PM To: Perl List Subject: RE: foreach question It's talking about stuff like this: $_='a,b,c,d,e,f,g,h,i,j,k,l'; forea

RE: foreach question

2001-07-24 Thread Mooney Christophe-CMOONEY1
It's talking about stuff like this: $_='a,b,c,d,e,f,g,h,i,j,k,l'; foreach $word (split /,/) { print $word; } foreach $word (grep /blah/, @somearray) { print $word; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: foreach question

2001-07-24 Thread Venkat Mohan
not confused any more In the above case split functions returns array of tokens. Hope this explains. -Original Message- From: Tom Malone [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 24, 2001 1:55 PM To: Perl List Subject: foreach question I am also a newbie, and I'm also curr

foreach question

2001-07-24 Thread Tom Malone
I am also a newbie, and I'm also currently on Chapter four of O'Reilly's Learning Perl. I just have a simple question about something I just read which confused me... In CH4, in the section on foreach loops, the book says, "If the list you are iterating over is made of real variables rather than