Hi there. I'm working on a program using the Expect module that connects to 3com switches and sucks out vlan information. I'm having a problem with a specific code block, related to the parsing of the returned data.
Here's a sample of the data, first.
It's in an array with each line being one element. I'm trying to go through this array and look to see if a line that doesn't have the unit number at the front of it is right after a unit line with the unit mumber at the front, merge the elements together. However, it's not working the way I expect it to. Here's the code:
Any help with this would be very much appreciated. I've been banging my head against the wall with it all day.
Here's a sample of the data, first.
Code:
1 none
1 none
1 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24
1 none
It's in an array with each line being one element. I'm trying to go through this array and look to see if a line that doesn't have the unit number at the front of it is right after a unit line with the unit mumber at the front, merge the elements together. However, it's not working the way I expect it to. Here's the code:
Code:
$size=@PortsArray;
$counter=0;
my $final;
while ($counter < $size)
{
if ($PortsArray[$counter] !~ m/^$UnitNumber/)
{
$PortsArray[$counter] =~ s/^\s+//;
my $prev = $counter - 1;
my $otherNewString = "$PortsArray[$counter]";
my $newString = "$PortsArray[$prev]";
$final = "$newString $otherNewString";
$PortsArray[$prev]="$otherNewString $newString";
$PortsArray[$counter]="";
}
$counter++;
}
Any help with this would be very much appreciated. I've been banging my head against the wall with it all day.