Hello
I put the strict and warning statements in my perl code. I now need
to initialize arrays. What is the best way to initialize an array
before the loop where I will basically recreating the array size in the loop?
my @array = ?
while (more work to do)
{
@array = split $string;
# do
On Tue, May 12, 2009 at 14:30, AndrewMcHorney wrote:
> Hello
>
> I put the strict and warning statements in my perl code. I now need to
> initialize arrays. What is the best way to initialize an array before the
> loop where I will basically recreating the array size in the loop?
>
> my @array = ?
AndrewMcHorney wrote:
Hello
Hello,
I put the strict and warning statements in my perl code. I now need to
initialize arrays. What is the best way to initialize an array before
the loop where I will basically recreating the array size in the loop?
my @array = ?
while (more work to do)
{
[stuff cut out]
It is usually best to declare variables in the smallest scope possible so:
while (more work to do)
{
my @array = split $string;
# do work on array
}
Doesn't that try to re-localize (?) the @array variable every time through
the loop? i.e. doesn't it re-run the my() fu
Bryan Harris wrote:
[stuff cut out]
It is usually best to declare variables in the smallest scope possible
so:
while (more work to do)
{
my @array = split $string;
# do work on array
}
Doesn't that try to re-localize (?) the @array variable every time
through the loop? i.e. doesn't
Bryan Harris wrote:
Doesn't that try to re-localize (?) the @array variable every time
through the loop? i.e. doesn't it re-run the my() function every time
through the loop? For some reason I thought that was a no-no.
my() happens when the code is compiled so it is *not* re-run every time
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every time
through the loop. The assignment happens when the code is run so it is
re-run every time.
$ perl -e '
for (1..5) {
my $count;
$count += 1;
print $count;
last if $count == 3;
}
print "\
From: "John W. Krahn"
> Bryan Harris wrote:
> >
> > [stuff cut out]
> >
> >> It is usually best to declare variables in the smallest scope possible
> >> so:
> >>
> >> while (more work to do)
> >> {
> >> my @array = split $string;
> >>
> >> # do work on array
> >> }
> >>
> >
> > Doesn't tha
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every
time through the loop. The assignment happens when the code is run so
it is re-run every time.
$ perl -e '
for (1..5) {
my $count;
$count += 1;
print $count;
last
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every
time through the loop. The assignment happens when the code is run
so it is re-run every time.
$ perl -e '
for (1..5) {
my $count;
$count += 1;
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every
time through the loop. The assignment happens when the code is run
so it is re-run every time.
$ perl -e '
for (1..5) {
my $c
On Tue, May 12, 2009 at 18:11, John W. Krahn wrote:
> Bryan Harris wrote:
>>
>> [stuff cut out]
>>
>>> It is usually best to declare variables in the smallest scope possible
>>> so:
>>>
>>> while (more work to do)
>>> {
>>> my @array = split $string;
>>>
>>> # do work on array
>>> }
>>>
>>
>> Do
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every
time through the loop. The assignment happens when the code is run
so it is re-run every time.
$ perl -e '
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
Gunnar Hjalmarsson wrote:
John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every
time through the loop. The assignment happens when the code is
run so it is re-run
On Wed, May 13, 2009 at 01:59, John W. Krahn wrote:
snip
>> What's your point?
>
> I am trying to understand what point you are trying to make.
snip
I believe the point is that declaration is only one of the things my
does, so saying that "my() happens when the code is compiled so it is
*not* re-
Chas. Owens wrote:
On Wed, May 13, 2009 at 01:59, John W. Krahn wrote:
snip
What's your point?
I am trying to understand what point you are trying to make.
snip
I believe the point is that declaration is only one of the things my
does, so saying that "my() happens when the code is compiled s
16 matches
Mail list logo