If you read packing hex you can find the answer there. What it boils down to is replacing convert($hexcommand) with pack ( "H*", $hexcommand ). That would make your script:

#!/usr/bin/perl use strict; use warnings; my $hexcommand="02313832300030010000c000003030353130303038313032343034 +34383236383331343135353430303030303030303030343135353430303003"; my $octcommand = pack ( "H*", $hexcommand ); print "DERRIVED OCTAL: $octcommand\n"; my $goodoct="\2\61\70\62\60\0\60\1\0\0\300\0\0\60\60\65\61\60\60\60\70 +\61\60\62\64\60\64\64\70\62\66\70\63\61\65\65\64\60\60\60\60\60\60\60 +\60\60\60\64\61\65\65\64\60\60\60\3"; print " GOOD OCTAL: $goodoct\n";

Although it appears that you are missing something in $goodoct because my result is:

DERRIVED OCTAL: 18200�00510008102404482683141554000000000041554 +000 GOOD OCTAL: 18200�00510008102404482683155400000000004155400 +0
l8rZ,
--
andrew

In reply to Re: Returning variable from sub by afresh1
in thread Returning variable from sub by cstrong

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.