in reply to Returning variable from sub
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
|
|---|