Anon Array

Discussion in 'Perl' started by The Owner, Feb 26, 2009.

  1. The Owner

    The Owner Guest

    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.
     
    The Owner, Feb 26, 2009
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. john
    Replies:
    0
    Views:
    543
  2. Olaf Petzold

    anon enums porting problem

    Olaf Petzold, Nov 8, 2005, in forum: C++
    Replies:
    0
    Views:
    489
    Olaf Petzold
    Nov 8, 2005
  3. neilmac
    Replies:
    2
    Views:
    1,037
    mcdjnaja
    Feb 7, 2008
  4. A L
    Replies:
    1
    Views:
    773
    Alf P. Steinbach /Usenet
    Aug 25, 2010
  5. ar
    Replies:
    1
    Views:
    298
    chrisrock
    Aug 4, 2004
  6. David

    Get username in Win/anon web

    David, Apr 3, 2006, in forum: ASP .Net Security
    Replies:
    1
    Views:
    279
    Dominick Baier [DevelopMentor]
    Apr 3, 2006
  7. Alex Washtell via .NET 247

    Web Service + Anon Access, but getting 401 Access Denied Error

    Alex Washtell via .NET 247, Apr 5, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    420
    Mauro Ottaviani [MSFT]
    Apr 5, 2005
  8. Andrew
    Replies:
    1
    Views:
    314
    Brian McCauley
    Jul 13, 2005
Loading...