Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So how do I now get access to what those arrays actually contain? E.g., how do I get:ARRAY(0x33b930) ARRAY(0x889eb0) ARRAY(0x8896b4) ARRAY(0x33b810)
Whenever I try, perl says the following:[ 1, 1, 1, 0, 1, 1, ], [ 1, 1, 1, 1, 0, 1, ], [ 1, 1, 0, 0, 0, 0, ], [ 0, 0, 1, 1, 1, 1, ],
Can't use string ("ARRAY(0x81e4c4)") as an ARRAY ref while "strict refs" in use at ./beispiel.plx line 36.
Any ideas? Am I going to have to try a completely different approach or is there a syntax for this?#!/usr/bin/perl # Input: A file containing vectors of 20 numbers, like: # 1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0 # 0,0,1,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,1,0 # Desired Output (see translation table below) # Odp- # kIr+ use strict; use warnings; my %translation = ( "i" => [ 1, 1, 1, 1, 1, 1, ], "I" => [ 1, 1, 0, 0, 1, 1, ], "o" => [ 1, 1, 1, 0, 1, 1, ], "u" => [ 1, 1, 1, 1, 0, 1, ], "O" => [ 1, 1, 0, 0, 0, 0, ], "p" => [ 0, 0, 1, 1, 1, 1, ], "d" => [ 0, 1, 1, 1, 1, 0, ], "k" => [ 0, 0, 1, 1, 0, 0, ], "f" => [ 0, 0, 1, 0, 1, 1, ], "s" => [ 0, 0, 1, 0, 0, 1, ], "r" => [ 0, 1, 0, 1, 0, 1, ], "/" => [ 0, 1, ], "+" => [ 1, 0, ], "*" => [ 1, 1, ], "-" => [ 0, 0, ], ); my %reverse_translation = reverse %translation; foreach my $key (keys %reverse_translation) { print STDERR $key . "\n"; # my @array = @{ $key }; # print join ",", @array; # print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem de-referencing a variable
by ikegami (Patriarch) on Feb 09, 2009 at 20:31 UTC | |
|
Re: Problem de-referencing a variable
by jwkrahn (Abbot) on Feb 09, 2009 at 20:40 UTC | |
|
Re: Problem de-referencing a variable
by Not_a_Number (Prior) on Feb 09, 2009 at 21:49 UTC |