Hey there
You need to build up the parameter array manually, with each individual element, not all in one string. This way system will call curl directly, and not via the shell where the quoting gets complicated:
use strict;
use warnings;
use Capture::Tiny qw/ capture /;
my ($to_id, $subject, $message) = qw(AA BB CC);
my @args = ( '-v', '-s', '--user', 'api:key*****',
'-F', "from=*****",
'-F', "to=Name <$to_id>",
'-F', "subject=$subject",
'-F', "text=$message",
'https://api.****/**/*****/messages',
);
my ($stdout,$stderr,$exit) = capture {
system 'curl', @args;
};
print $stdout,$stderr,$exit;
Added -v to the options so that you can see what is going on, although you wont want that once you get things sorted out. Another option is WWW::Curl on CPAN which has a Perl API overtop of Curl.