how to initialize a 2d array in perl

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-03-13T02:40:53Z Indexed on 2010/03/13 2:47 UTC
Read the original article Hit count: 368

Filed under:
|

How do I initialize a 2d array in perl?

I am trying the following code:

 0 use strict;
10 my @frame_events = (((1) x 10), ((1) x 10));
20 print "$frame_events[1][1]\n";

but it gives the following error:

Can't use string ("1") as an ARRAY ref while "strict refs" in use at ./dyn_pf.pl line 20.

This syntax only seems to initialize a 1d array as print "$frame_events[1]\n" works. Though perl doesn't give any error during the assignment.

© Stack Overflow or respective owner

Related posts about perl

Related posts about arrays