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
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;
>
> 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
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);
"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
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
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
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++)
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
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
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
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;
>
>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
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
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
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]
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
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
18 matches
Mail list logo