#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @tmp_container=(); $tmp_container[0]->[0]->[0] = 'CIS'; $tmp_container[0]->[0]->[1] = 'P1'; $tmp_container[0]->[0]->[2] = 'A1'; $tmp_container[0]->[1]->[0] = 'off'; $tmp_container[0]->[2]->[0] = 'AAA'; $tmp_container[0]->[2]->[1] = 'xxx'; $tmp_container[0]->[3]->[0] = 'on'; #------------------------------------ $tmp_container[1]->[0]->[0] = 'AAA'; $tmp_container[1]->[0]->[1] = 'yyy'; $tmp_container[1]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[2]->[0]->[0] = 'AAA'; $tmp_container[2]->[0]->[1] = 'zzz'; $tmp_container[2]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[3]->[0]->[0] = 'BBB'; $tmp_container[3]->[0]->[1] = 'xxx'; $tmp_container[3]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[4]->[0]->[0] = 'BBB'; $tmp_container[4]->[0]->[1] = 'yyy'; $tmp_container[4]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[5]->[0]->[0] = 'BBB'; $tmp_container[5]->[0]->[1] = 'zzz'; $tmp_container[5]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[6]->[0]->[0] = 'CIS'; $tmp_container[6]->[0]->[1] = 'P1'; $tmp_container[6]->[0]->[2] = 'A2'; $tmp_container[6]->[1]->[0] = 'off'; $tmp_container[6]->[2]->[0] = 'AAA'; $tmp_container[6]->[2]->[1] = 'xxx'; $tmp_container[6]->[3]->[0] = 'on'; #------------------------------------ $tmp_container[7]->[0]->[0] = 'AAA'; $tmp_container[7]->[0]->[1] = 'yyy'; $tmp_container[7]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[8]->[0]->[0] = 'AAA'; $tmp_container[8]->[0]->[1] = 'zzz'; $tmp_container[8]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[9]->[0]->[0] = 'BBB'; $tmp_container[9]->[0]->[1] = 'xxx'; $tmp_container[9]->[1]->[0] = 'on'; #------------------------------------ #print Dumper(\@tmp_container); my @add; for my $arr (@tmp_container) { if(@{$arr->[0]}>2) { @add=($arr->[0],$arr->[1]); } else { my @add1=@{$add[0]}; my @add2=@{$add[1]}; unshift(@{$arr},\@add1,\@add2); } } #print Dumper(\@tmp_container); print "\n1: ".$tmp_container[0]."\n"; print "\n2: ".$tmp_container[0]->[0]."\n"; print "\n3: ".$tmp_container[0]->[0]->[0]."\n"; print "\n1: ".$tmp_container[1]."\n"; print "\n2: ".$tmp_container[1]->[0]."\n"; print "\n3: ".$tmp_container[1]->[0]->[0]."\n"; print "\n1: ".$tmp_container[2]."\n"; print "\n2: ".$tmp_container[2]->[0]."\n"; print "\n3: ".$tmp_container[2]->[0]->[0]."\n";