sub gen2nfs_sub_ifconfig_mac { my $ethif = shift; my $ifconfig = "$IFCONFIG"; my $string = 'HWaddr'; local *IFCONFIG; open (IFCONFIG, "$ifconfig $ethif 2>&1 |") || die ("ERROR (gen2nfs_sub_ifconfig_mac): $! $_"); while() { # search MAC 00:00:00:00:00:00 # ww:ww:ww:ww:ww:ww # \w = word if ( /^.*$string\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ) { return "$1"; last; } else { die ("ERROR (gen2nfs_sub_ifconfig_mac): $! $_" ); }; } close (IFCONFIG); }