in reply to Returning variable from sub

The convention of using a backslash and digits to get octal values into a string is only needed for string literals.

In your case, you know the value of the byte you want in the string ($dec), so you can add it to the string with:

$octcommand = $octcommand . chr $dec;
That explains why your code isn't doing what you expect. However, don't just do that: I second afresh1's suggestion of using pack. No need to implement pack when it's already part of the language :-)

--
.sig : File not found.