sub get_measures { my $device = qr/\A\Q$_[0]\E\s/; # pass device name as first argument local $/ = ''; # paragraph mode my ( $recv, $sent ) = map { /$device/ && /RX bytes\:(\d+) .*?TX bytes\:(\d+)/ ? int( $1 / 1024 ), int( $2 / 1024 ) : () } qx[/sbin/ifconfig]; return $recv, $sent; }