Bizarre copy of ARRAY

J

Joachim Fabini

Hi,

Being a complete newbie in Perl, before submitting the bug to
ActiveState I'd like to cross-check if the following error message is
caused by a coding error or by a bug in the debugging part of Perl.

When running the code from the command line everything works as
expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
script using perl -d BugTest.pl, the debugger stops and displays the
following message:
Bizarre copy of ARRAY in leave at BugTest.pl line 16.
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.

Below the script:
-------------------------------------------------------------------------
#!/usr/bin/perl

use strict;

my %Tests =
(
"HTTP" => ["a","b","1K","10K"],
"SMTP" => ["c","d","1K","10K","100K"]
);


for my $CurrentTest (keys %Tests)
{
# Execute test
my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest} };
for my $i (0 .. $#{@FileSizes} )
{
print "Test: $CurrentTest, Iteration: $i, FileSize:
@FileSizes[$i]\n";
}
}

-------------------------------------------------------------------------

Thanks in advance for any reply,

Best regards
--Joachim
 
G

Greg Bacon

: When running the code from the command line everything works as
: expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
: script using perl -d BugTest.pl, the debugger stops and displays the
: following message:
:
: > Bizarre copy of ARRAY in leave at BugTest.pl line 16.
: > Debugged program terminated. Use q to quit or R to restart,
: > use O inhibit_exit to avoid stopping after program termination,
: > h q, h R or h O to get additional info.

You're abusing syntax. $#{...} expects a reference inside the block,
and to pluck a scalar from an array, say $array[$index]:

#!/usr/bin/perl

use strict;

my %Tests =
(
"HTTP" => ["a","b","1K","10K"],
"SMTP" => ["c","d","1K","10K","100K"]
);

for my $CurrentTest (keys %Tests)
{
# Execute test
my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest}};
for my $i (0 .. $#FileSizes )
{
print "Test: $CurrentTest, Iteration: $i, FileSize:\n",
$FileSizes[$i], "\n";
}
}

Hope this helps,
Greg
 
A

AlV

Joachim said:
Hi,

Being a complete newbie in Perl, before submitting the bug to
ActiveState I'd like to cross-check if the following error message is
caused by a coding error or by a bug in the debugging part of Perl.

When running the code from the command line everything works as
expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
script using perl -d BugTest.pl, the debugger stops and displays the
following message:

Try the slight modification below.
Below the script:
-------------------------------------------------------------------------
#!/usr/bin/perl

use strict;

my %Tests =
(
"HTTP" => ["a","b","1K","10K"],
"SMTP" => ["c","d","1K","10K","100K"]
);


for my $CurrentTest (keys %Tests)
{
# Execute test
my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest} };
### for my $i (0 .. $#{@FileSizes} ) #### Bizarre, indeed! :eek:)

for my $i (0 .. $#FileSizes )
{
print "Test: $CurrentTest, Iteration: $i, FileSize:
@FileSizes[$i]\n";
}
}
 
J

Joachim Fabini

On Tue, 07 Oct 2003 14:03:53 +0200, Joachim Fabini

Thanks to all who replied - replacing $#{@FileSizes} by $#FileSizes
does the job.

Best regards
--Joachim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top