Perhaps the following will be helpful:
use strict;
use warnings;
print "Interface Name,Vlan Id,IP Address\n";
while (<DATA>) {
my $interface = /interfaces\s+(\S+)\s+/ ? $1 : q/''/;
my $vlanID = /unit\s+(\S+)\s+/ ? $1 : q/''/;
my $ip = /address\s+(\S+)\s+/ ? $1 : q/''/;
print "$interface,$vlanID,$ip\n";
}
__DATA__
set interfaces ge-1/0/0 unit 0 family inet address 10.100.200.1/24 arp 10.100.200.2 mac 00:16:d4:e7:9b:de
set interfaces ge-1/0/2 description "NodeB_Cluster/1211-3-PEG16#14"
set interfaces ge-1/0/2 unit 101 family inet address 10.187.132.3/27 vrrp-group 1 virtual-address 10.187.132.1
set interfaces ge-1/0/2 unit 102 family inet address 10.187.132.35/27 vrrp-group 2 virtual-address 10.187.132.33
set interfaces ge-1/0/6 description "BB_GSM_1x_1GE_#1_ae2_to_BA-JKCTO-02_ge-1/0/1"
set interfaces ge-1/0/6 gigether-options no-auto-negotiation
set interfaces ge-1/0/6 gigether-options 802.3ad ae2
Output:
Interface Name,Vlan Id,IP Address
ge-1/0/0,0,10.100.200.1/24
ge-1/0/2,'',''
ge-1/0/2,101,10.187.132.3/27
ge-1/0/2,102,10.187.132.35/27
ge-1/0/6,'',''
ge-1/0/6,'',''
ge-1/0/6,'',''
solved perl grep with / on array