> "sw" == shawn wilson writes:
sw> On Jun 3, 2011 3:17 PM, "Uri Guttman" wrote:
>>
>>
>> perl -le 'my $x = "zzz" ; for $x ( qw( foo bar ) ) { print "L: $x" } print
sw> "E: $x"'
>> L: foo
>> L: bar
>> E: zzz
sw> That's odd, I would have thought that would have given 'foo
On Jun 3, 2011 3:17 PM, "Uri Guttman" wrote:
>
>
> perl -le 'my $x = "zzz" ; for $x ( qw( foo bar ) ) { print "L: $x" } print
"E: $x"'
> L: foo
> L: bar
> E: zzz
>
That's odd, I would have thought that would have given 'foo bar bar'. So,
how would you keep data from a loop once you're outside of
> "R" == Ruud writes:
R> On 2011-06-03 17:37, sono...@fannullone.us wrote:
>> Maybe it's too early in the morning here, but I can't seem to remember how
to use a lexical $variable that is defined inside a foreach loop, outside of
that loop.=:\
>>
>> Here's the loop:
>>
>>
On 2011-06-03 17:37, sono...@fannullone.us wrote:
Maybe it's too early in the morning here, but I can't seem to remember
how to use a lexical $variable that is defined inside a foreach loop, outside
of that loop.=:\
Here's the loop:
foreach my $name (split
On Jun 3, 2011, at 1:38 PM, Shawn H Corey wrote:
> That implies something is wrong with your logic.
Yep. I came to the same conclusion. =:)
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 11-06-03 03:58 PM, sono...@fannullone.us wrote:
I wasn't very clear in what I wanted. Sorry. I wanted to use the value of
$name in another loop but after testing
That implies something is wrong with your logic. The question is: what
value of $name do you want? The first? The last? E
On Jun 3, 2011, at 10:22 AM, Uri Guttman wrote:
>> s>my $sortstr = substr("00$totalcells", -2);
> that looks like you are forcing leading 0's. the common idiom for that
> is sprintf "%02d", $totalcells. your way works but is harder to read.
Thanks, Uri. I didn't catch that.
> "BF" == Brian Fraser writes:
BF> On Fri, Jun 3, 2011 at 1:23 PM, Jim Gibson wrote:
>> Declare the variable just before the loop, and remove the 'my' from the
>> foreach statement:
>>
>> my $name;
>> foreach $name ( ... ) {
>> ...
>> }
>>
BF> That won't do. What that
On Fri, Jun 3, 2011 at 1:23 PM, Jim Gibson wrote:
> Declare the variable just before the loop, and remove the 'my' from the
> foreach statement:
>
> my $name;
> foreach $name ( ... ) {
> ...
> }
>
That won't do. What that code actually translated to is
my $name;
for my $name ( ... ) { ... }
Wi
> "s" == sono-io writes:
s>Maybe it's too early in the morning here, but I can't seem to remember
how to use a lexical $variable that is defined inside a foreach loop, outside
of that loop.=:\
s>Here's the loop:
s>foreach my $name (split (/, */, $names)) {
On 11-06-03 11:37 AM, sono...@fannullone.us wrote:
I want to use "$name" in another loop just after this one, but when I do, I get
"Global symbol $name requires explicit package".
Could someone please point me in the right direction?
Certainly. The variable used in a foreach loop is
C.DeRykus wrote:
> One option is an outer enclosing block that'll extend the scope of $name to
> that entire block:
Jim Gibson wrote:
> Declare the variable just before the loop, and remove the 'my' from the
> foreach statement:
Thanks for the responses. I was able to get it to work
On Jun 3, 8:37 am, sono...@fannullone.us wrote:
> ...
> I want to use "$name" in another loop just after this one, but when I
> do, I get "Global symbol $name requires explicit package".
>
One option is an outer enclosing block that'll
extend the scope of $name to that entire block:
At 8:37 AM -0700 6/3/11, sono...@fannullone.us wrote:
Maybe it's too early in the morning here, but I can't seem to
remember how to use a lexical $variable that is defined inside a
foreach loop, outside of that loop.=:\
Here's the loop:
foreach my $name (split (/,
On Jun 3, 2011, at 8:45 AM, Alan Haggai Alavi wrote:
> Here, the scope of $name is limited to the foreach loop and not outside it.
> So, you will have to declare the variable again for use outside the loop.
But wouldn't that make the second "$name" a different variable? I'm
not at my c
Hello,
> foreach my $name (split (/, */, $names)) {
Here, the scope of $name is limited to the foreach loop and not outside it.
So, you will have to declare the variable again for use outside the loop.
Regards,
Alan Haggai Alavi.
--
The difference makes the difference.
--
To un
Maybe it's too early in the morning here, but I can't seem to remember
how to use a lexical $variable that is defined inside a foreach loop, outside
of that loop.=:\
Here's the loop:
foreach my $name (split (/, */, $names)) {
next unle
17 matches
Mail list logo