--- Bob Mangold <[EMAIL PROTECTED]> wrote:
> Date: Tue, 19 Jun 2001 19:40:51 -0700 (PDT)
> From: Bob Mangold <[EMAIL PROTECTED]>
> Reply-to: [EMAIL PROTECTED]
> Subject: Re: variable losing it's value
> To: Michael Fowler <[EMAIL PROTECTED]>
>
> B
On Jun 19 2001, Bob Mangold wrote:
> my ($line) = "hello";
> foreach $line (<>){
> . whatever
> }
> print $line;
This code snippet will print "hello", since the foreach loop
gives its iterator variable an implicit declaration with
"local", AFAIK.
[]s, Ro
On Tue, Jun 19, 2001 at 09:39:13PM -0400, Eric Beaudoin wrote:
> At 16:39 2001.06.19, Jeff 'japhy' Pinyan wrote:
> >This is because the looping variable is implicitly localized to the loop
> >itself. This is not a bug.
>
> Has this always been the case? I was under the impression that the syntax
At 16:39 2001.06.19, Jeff 'japhy' Pinyan wrote:
>On Jun 19, Bob Mangold said:
>
>>I may have a bug somewhere in my code, but I can't find it. Before I
>>look again though please answer this for me.
>
>>my ($line) = "hello";
>>foreach $line (<>){
>> . whatever
>>}
>>print $line;
>>
>>Should
On Tue, Jun 19, 2001 at 02:41:40PM -0700, Bob Mangold wrote:
[snip]
> except I can't just type 'foreach my($line) (<>)'.
That's because your syntax is wrong. It should be:
foreach my $line (<>) {
Assuming you actually want to use foreach for such a thing. What you really
should be using i
The standard idiom is:
foreach my $item (@items) {
}
On 19 Jun 2001 14:41:40 -0700, Bob Mangold wrote:
> Thanks, that's what I thought was happening, but now I have another question.
> If I 'use strict' (and who doesn't), I am forced to declare $line before the
> foreach loop, except I can't jus
Thanks, that's what I thought was happening, but now I have another question.
If I 'use strict' (and who doesn't), I am forced to declare $line before the
foreach loop, except I can't just type 'foreach my($line) (<>)'. I have to type
it on a preceeding line. If this is the case then why does perl
On Jun 19, Bob Mangold said:
>I may have a bug somewhere in my code, but I can't find it. Before I
>look again though please answer this for me.
>my ($line) = "hello";
>foreach $line (<>){
> . whatever
>}
>print $line;
>
>Should it print the last line in <> or 'hello'?
I don't think th
You are overlaying $line each time you read a line from <>. SO it will be
the last line from whatever files if any were passed.
Wags ;)
-Original Message-
From: Bob Mangold [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 19, 2001 13:25
To: [EMAIL PROTECTED]
Subject: variable losin
When you do : foreach $line (<>){
that will print the last line in <>
rename $line in the foreach statement to something different,
RYan
On Tue, 19 Jun 2001, Bob Mangold wrote:
> I may have a bug somewhere in my code, but I can't find it. Before I look again
> though please answer this for
I may have a bug somewhere in my code, but I can't find it. Before I look again
though please answer this for me.
If I execute:
my ($line) = "hello";
foreach $line (<>){
. whatever
}
print $line;
Should it print the last line in <> or 'hello'?
-Bob
11 matches
Mail list logo