Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Multidimensional arrays

by tybalt89 (Monsignor)
on Mar 26, 2020 at 17:04 UTC ( [id://11114685]=note: print w/replies, xml ) Need Help??


in reply to Multidimensional arrays

There are other ways, too...

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11114679 use warnings; use Data::Dump qw(pp dd); my $A = [[1,2],[2,3]]; my $B = eval pp $A; sub add1 { ref $_[0] ? [ map add1($_), @{$_[0]} ] : $_[0] + 1 } my $incremented = add1( $A ); dd $A; dd $B; dd $incremented;

Outputs:

[[1, 2], [2, 3]] [[1, 2], [2, 3]] [[2, 3], [3, 4]]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found