Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Bizarre copy of ARRAY

Reply
Thread Tools

Bizarre copy of ARRAY

 
 
Joachim Fabini
Guest
Posts: n/a
 
      10-07-2003
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
 
Reply With Quote
 
 
 
 
Greg Bacon
Guest
Posts: n/a
 
      10-07-2003
In article <(E-Mail Removed)>,
Joachim Fabini <(E-Mail Removed)> wrote:

: 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
--
The moral is obvious. You can't trust code that you did not totally create
yourself. (Especially code from companies that employ people like me.)
-- Ken Thompson
 
Reply With Quote
 
 
 
 
AlV
Guest
Posts: n/a
 
      10-07-2003
Joachim Fabini wrote:
> 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! )


for my $i (0 .. $#FileSizes )

> {
> print "Test: $CurrentTest, Iteration: $i, FileSize:
> @FileSizes[$i]\n";
> }
> }


 
Reply With Quote
 
Joachim Fabini
Guest
Posts: n/a
 
      10-07-2003
On Tue, 07 Oct 2003 14:03:53 +0200, Joachim Fabini
<(E-Mail Removed)> wrote:

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

Best regards
--Joachim

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Bizarre copy of HASH in sassign..." bug kj Perl Misc 2 08-12-2010 05:10 PM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
Bug in debugger (or my code): Bizarre copy of ARRAY... vnick@freenet.de Perl Misc 12 10-06-2005 11:43 AM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
"Bizarre copy of array in aassign" John Perl Misc 0 04-19-2004 06:19 PM



Advertisments