Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: reading input into a number of arrays

by choroba (Cardinal)
on Feb 25, 2020 at 16:07 UTC ( [id://11113411]=note: print w/replies, xml ) Need Help??


in reply to reading input into a number of arrays

Perl doesn't support the comma separated indices for multidimensional arrays. Instead of
$a[$i, 1]

use

$a[$i][1]

Update: Use warnings, Perl will tell you:

Multidimensional syntax $a[$i,1] not supported at ...

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: reading input into a number of arrays
by tobyink (Canon) on Feb 25, 2020 at 21:41 UTC

    You can emulate multi-dimentional arrays with hashes though. It's a feature not many people use.

    my %multidim; my $x = 3; my $y = 4; $multidim{ $x, $y } = 42; print $multidim{ $x, $y }, "\n";
Re^2: reading input into a number of arrays
by Dannypje (Initiate) on Feb 25, 2020 at 16:11 UTC
    Choroba, thanks! I knew this. My shame is infinite.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found