I see hdb has shown the syntax you requested. Be aware that splice can be slow and there are often better alternatives. For instance, if you had intended to use splice to remove lowercase characters, you could have rewritten that entire block of code above as:
for (@MainArray) { @$_ = grep { ! /[a-z]/ } @$_; }
Here's my test:
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my @MainArray; # Original array populating code while (<DATA>) { chomp; push @MainArray, [ split // ]; } # New alternative to 'splice' code for (@MainArray) { @$_ = grep { ! /[a-z]/ } @$_; } print Dumper \@MainArray; __DATA__ Hello my name is Jack
Output:
$ pm_file_chars_to_AoA_2.pl $VAR1 = [ [ 'H' ], [], [], [], [ 'J' ] ];
-- Ken
In reply to Re^3: Parse txt file into array of array
by kcott
in thread Parse txt file into array of array
by Dr Manhattan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |