use Encode qw( encode ); open(my $fh, '>:raw', $qfn) or die("Can't create \"$qfn\": $!\n"); print($fh join("\x01", map encode($encoding, $_), @values));
Of course, in most encodings (and UTF-8 in particular), U+0001 encodes as 01, so you can use an :encoding layer as normal.
use open ':encoding(UTF-8)'; open(my $fh, '>', $qfn) or die("Can't create \"$qfn\": $!\n"); print($fh join("\x01", @values);
Finally, if the values are terminated by 01 rather than separated by 01, you'd use
use open ':encoding(UTF-8)'; open(my $fh, '>', $qfn) or die("Can't create \"$qfn\": $!\n"); print($fh "$_\x01") for @values;
or
use open ':encoding(UTF-8)'; open(my $fh, '>', $qfn) or die("Can't create \"$qfn\": $!\n"); local $\ = "\x01"; print($fh $_) for @values;
The last one might be tempting, but the global nature of the change to $\ could negatively affect code in modules.
In reply to Re: Creating data delimited by ASCII code 1 using perl
by ikegami
in thread Creating data delimited by ASCII code 1 using perl
by dasun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |