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?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    0
    Views:
    537
  2. Olaf Petzold

    anon enums porting problem

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

    Get username in Win/anon web

    David, Apr 3, 2006, in forum: ASP .Net Security
    Replies:
    1
    Views:
    274
    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:
    415
    Mauro Ottaviani [MSFT]
    Apr 5, 2005
  8. Andrew
    Replies:
    1
    Views:
    310
    Brian McCauley
    Jul 13, 2005
Loading...