my $data = "\x58\x02\x77\x21\x1F"; my $rain_clicks = Int(substr($data, 0, 2)); my $rain_rate = Int(substr($data, 2, 2)); my $uv_index = ord(substr($data, 4, 1));
- Could be written as:
my($rain_clicks, $rain_rate, $uv_index) = unpack('SSC', $data);
my $data = "\x58\x02\x77\x21\x1F"; my $rain_clicks = Int(substr($data, 0, 2)); my $rain_rate = Int(substr($data, 2, 2)); my $uv_index = ord(substr($data, 4, 1));
my($rain_clicks, $rain_rate, $uv_index) = unpack('SSC', $data);