Declare data as a variable that points to the same absolute address as the string s. The type pbyte (pointer to a byte) can be accessed as an array, so data[0] is the first byte of the string.
use v5.10;
useopen':std', ':encoding(UTF-8)';
use utf8;
Importing utf8 allows UTF-8 in the script; open sets UTF-8 encoding on stdout and stdin.
Encode's encode() function is used to convert the $text variable from a perl internal string to a UTF-8 string, which is then passed to unpack with a 'C*' template and converted into a list of bytes.