in reply to measuring IN/OUT traffic on your computer

se strict;

Produces the error message:

Can't locate object method "se" via package "strict" (perhaps you forg +ot to load "strict"?)
my $data = `/sbin/ifconfig | grep “RX bytes” | head -1`;

I guess you are assuming that the "certain device" you want information on is the first device listed by ifconfig?

$data =~ /RX bytes\:(\d+) .*TX bytes\:(\d+) .*/; my $recv = $1/1024; my $sent=$2/1024; $recv =~ s/\..*//; $sent =~ s/\..*//;

You shouldn't use the variables $1 and $2 unless the regular expression matched correctly otherwise the values in $1 and $2 will be from the last successful match. Is there any reason that you didn't use the int function instead of the substitution operator?

You probably want something like this:

sub get_measures { my $device = qr/\A\Q$_[0]\E\s/; # pass device name as first argum +ent 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; }