There's too much hand-waving (or ellipses) to answer with code. But try it yourself.

server.pl

#! /usr/bin/perl use warnings; use strict; use Plack::Builder; use Plack::Request; use Data::Dumper; my $APP = sub { my ($env) = @_; my $req = 'Plack::Request'->new($env); [200, [], [Dumper($req)]] }; builder { mount '/' => $APP; };

client.pl

#!/usr/bin/perl use warnings; use strict; use Encode; use Digest::SHA; use MIME::Base64 qw{ encode_base64 }; use LWP::UserAgent; my $ua = 'LWP::UserAgent'->new; my $url = 'http://localhost:5000'; my $str = 'hello'; # no special chars, 1-127 my $sha256 = Digest::SHA::sha256('abc123'); # bytes 0-255 my $hmac = Digest::SHA::hmac_sha512('a message', 'a key'); # bytes 0-2 +55 my $unicode_string = "\N{GREEK SMALL LETTER ALPHA}\N{GREEK SMALL LETTE +R BETA}ab123"; # unicode chars mixed with lower-ascii my $buffer = ""; # buffer to concatenate above into and POST them for($str, $sha256, $hmac, $unicode_string){ $buffer .= Encode::encode('UTF-8', $_); } my $b64 = encode_base64($buffer); my @HTTPHeader = (ABC => $b64); my $response = $ua->post($url, @HTTPHeader, Content => $b64); # <-- C +hange to your liking. use Data::Dumper; print Dumper $response->content; ...

Now, run the server in one terminal and the client in another.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Perl strings questions by choroba
in thread Perl strings questions by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.