in reply to element of an array of arrays
You don't actually have an array of arrays:
use Data::Printer; p @Records; p @RecCheck;
[ [0] "AAA,20130610,730,1015, ", [1] "BBB,20130610,1015,1200, ", [2] "CCC,20130610,1230,1400, ", [3] "DDD,20130610,1415,1530, " ] [ [0] "AAA,20130610,730,1015, ", [1] "BBB,20130610,1015,1200, ", [2] "CCC,20130610,1230,1400, ", [3] "DDD,20130610,1415,1530, " ]
I left your @Records almost as is (only removed new line) and changed @RecCheck so that it would be an array of arrays like I think you wanted:
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use Data::Printer; my @Records; push( @Records, join ',', ( "AAA", 20130610, 730, 1015 ) ); push( @Records, join ',', ( "BBB", 20130610, 1015, 1200 ) ); push( @Records, join ',', ( "CCC", 20130610, 1230, 1400 ) ); push( @Records, join ',', ( "DDD", 20130610, 1415, 1530 ) ); my @RecordRowFields; my @RecCheck; for my $RecordRow (@Records) { @RecordRowFields = split /,/, $RecordRow; push( @RecCheck, [@RecordRowFields] ); } say "Single element: $RecCheck[1][2]"; p @RecCheck; __END__ [ [0] [ [0] "AAA", [1] 20130610, [2] 730, [3] 1015 ], [1] [ [0] "BBB", [1] 20130610, [2] 1015, [3] 1200 ], [2] [ [0] "CCC", [1] 20130610, [2] 1230, [3] 1400 ], [3] [ [0] "DDD", [1] 20130610, [2] 1415, [3] 1530 ] ] Single element: 1015
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: element of an array of arrays
by JockoHelios (Scribe) on Jun 17, 2013 at 02:21 UTC | |
by frozenwithjoy (Priest) on Jun 17, 2013 at 02:24 UTC | |
by Anonymous Monk on Jun 17, 2013 at 03:09 UTC | |
by Anonymous Monk on Jun 17, 2013 at 03:11 UTC |