The VMS::DCLsym module has been part of the Perl core distribution for many years and makes it easy to store the return value of a function (or anything else) in a DCL symbol. Here's an example:
$ perl -"MVMS::DCLsym" -e "$x = sprintf('0x%x', 99); VMS::DCLsym->setsym('X', $x, 'GLOBAL');"
$ show symbol x
X == "0x63"
Also, by default, the %ENV hash is mapped to supervisor-mode process logical names, meaning they persist after Perl exits. So here's another way to leave something behind for the CLI when Perl exits:
$ perl -e "$ENV{'X'} = sprintf('0x%x', 99);"
$ show logical x
"X" = "0x63" (LNM$PROCESS_TABLE)
$ x = f$trnlnm("X")
$ show symbol x
X = "0x63"
If the only thing you want to pass back to DCL is an integer value, you can just exit Perl with that value and retrieve it from the $STATUS symbol that is always available in DCL:
$ perl -e "exit 99;"
$ show symbol $status
$STATUS == "%X00000063"
But there are complications here, since the CLI will interpret that value as success (odd values) or failure (even values), in the latter case invoking any relevant warning or error handlers you have set up and attempting to retrieve message text, if there is any. In other words, exit statuses are expected to actually mean something to DCL, such as in this famous Easter Egg:
$ perl -e "exit 2928;"
%SYSTEM-W-FISH, my hovercraft is full of eels
You can suppress the printing of the message with the "vmsish 'hushed'" pragma, and while you're at it you'll want to also use the "vmsish 'exit'" pragma to prevent the mapping of 0 to a generic success value and 1 to a generic failure value, assuming those are in the range of numbers you might be returning. So that would look something like:
$ perl -e "use vmsish 'hushed','exit'; exit 2928;"
$ show symbol $status
$STATUS == "%X10000B70"
Note that handlers may still be invoked for even-numbered exit values.