use Net::Interface qw( mac_bin2hex ); my @all_ifs = Net::Interface->interfaces; print "Mac addresses of ethernet interfaces on this machine:\n"; for ( grep { $_->name =~ m/^eth\d/ } @all_ifs ) { print mac_bin2hex( scalar $_->hwaddress ),"\n"; }