Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: dereference array of array

by LanX (Canon)
on Jan 21, 2013 at 11:19 UTC ( #1014425=note: print w/ replies, xml ) Need Help??


in reply to dereference array of array

use Data::Dumper ?

UPDATE

TIMTOWTDI

DB<100> @result=([1..3],[4..6],[7..9]) => ([1, 2, 3], [4, 5, 6], [7, 8, 9]) DB<101> print @{$result[1]} => 1 456 DB<102> $,=','; print @{$result[1]} => 1 4,5,6 DB<103> print "@{$result[1]}" => 1 4 5 6 DB<104> use Data::Dumper => 0 DB<105> print Dumper $result[1] $VAR1 = [ 4, 5, 6 ]; => 1 DB<106> print Dumper \@result $VAR1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; => 1

UPDATE
DB<118> $Data::Dumper::Indent=0 => 0 DB<119> $Data::Dumper::Terse =1 => 1 DB<120> print Dumper \@result => 1 [[1,2,3],[4,5,6],[7,8,9]]

Cheers Rolf


Comment on Re: dereference array of array
Select or Download Code
Re^2: dereference array of array
by moadeep (Novice) on Jan 21, 2013 at 11:41 UTC
    Thanks Rolf, Dumper does indeed give me the numbers I wish. However the format -
    $VAR1 = [ '11', '40', '13', '11', '3', '4' ];
    is not ideal. I really need it in the form 11 40 13 11 3 4 so I can pass it into a subroutine for creating a latex table. Any ideas

    Update

    @{$results[0]} worked thanks
      see all examples given in my reply.

      you can also manipulate $, for simple prints and $" for double-quoted expressions or just join.

      plz use <code> and <p> tags.

      UPDATE

      PLZ! when updating a post don't simply delete what you wrote before!!!

      Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-12-20 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (96 votes), past polls