D
Domenico Discepola
Hello. Given a variable $delete_col, how can I "delete" an entire array
"column" and "move" the remaining columns to the left? E.g. how do I turn:
( ["a", "b", "c"], ["1", "2", "3"] ) into ( ["a", "c"], ["1", "3"] ) given
that the value of $delete_col = 1?
TIA
#########
#!perl
use strict;
use warnings;
my $delete_col = 1;
my @arr01 = ( ["a", "b", "c"], ["1", "2", "3"] );
my ( $row, $col ) = 0;
foreach ( @arr01 ) {
#Get # cols in array
my $tot_cols = ( $#{$arr01[$row]} );
for ($col=0;$col<=$tot_cols;$col++) {
#Printing just for an example
if ( $col == $tot_cols ) {
print "$arr01[${row}][${col}]" ;
} else {
print "$arr01[${row}][${col}]:" ;
}
}
print "\n";
$row++;
}
exit 0;
"column" and "move" the remaining columns to the left? E.g. how do I turn:
( ["a", "b", "c"], ["1", "2", "3"] ) into ( ["a", "c"], ["1", "3"] ) given
that the value of $delete_col = 1?
TIA
#########
#!perl
use strict;
use warnings;
my $delete_col = 1;
my @arr01 = ( ["a", "b", "c"], ["1", "2", "3"] );
my ( $row, $col ) = 0;
foreach ( @arr01 ) {
#Get # cols in array
my $tot_cols = ( $#{$arr01[$row]} );
for ($col=0;$col<=$tot_cols;$col++) {
#Printing just for an example
if ( $col == $tot_cols ) {
print "$arr01[${row}][${col}]" ;
} else {
print "$arr01[${row}][${col}]:" ;
}
}
print "\n";
$row++;
}
exit 0;