#!/usr/bin/perl use warnings; use strict; use Data::Dumper; ################ my @AoH; open my $fh, '<', 'interface.txt' or die "Cannot open 'interface.txt' because: $!"; while ( <$fh> ) { if ( / ^ ( \w+ \d ) : \s+ flags= ( \S+ ) /x ) { push @AoH, { interface => $1, flags => $2 }; } elsif ( / ( ether | media | inet | status ) :? \s+ ( \S+ ) /x ) { $AoH[ -1 ]{ $1 } = $2; } } close $fh; print Dumper \@AoH;