Anon Array

T

The Owner

Hi,

I'm looking for a better way to use the contents of an anonymous array.
This is what I've done so far:

#!/usr/bin/perl
#

use strict;
use Data::Dumper;

my (%test,@numbers,$key,$value,$index);

@numbers = (1,2,3);

$test{"base_0"} = [ @numbers ];
print STDOUT ("test\{\"base_0\"\}= ".Dumper($test{"base_0"})."\n");
$test{"base_10"} = [ map ($_+10, @numbers)];
print STDOUT ("test\{\"base_10\"\}= ".Dumper($test{"base_10"})."\n");

foreach $key (sort keys (%test))
{
print STDOUT ("ref\(test\{$key\}\)= ".ref($test{$key})."\n");
$index = 0;
until (!$test{$key}[$index])
{
print STDOUT ("value\[$index\]= ".$test{$key}[$index]."\n");
$index ++;
}
}

It's kinda ugly to do it this way. Any suggestion(s)? Thanks.
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top