I wonder if UTF-8 is automatically selected as I don't turn it on at all. Here's the full code.

#!/usr/bin/perl -w use strict; use LWP; use Getopt::Long; ## ## GLobal variables ## my $primary_server = ""; my $timeout = 30; # No. of seconds to wait for request to timeout my $uagent; # User Agent object my $line; # A Line read from the order file my $mtid; # First 4 digits of the input line my $bits; # Bit flags (64 or 128, first bit of 1 = 128) my $bitsize; # The length of bit flags (either 64 or 128) my $byte; # eight bit flags. my $data; # The data my $reqsize; # The length of the fully packed request. my $request; # Holds the full request line converted to binary my $cmd_line; # Holds the xml command to submit my $reply; # Holds raw reply from server my $error_flag; # Err flag (0=no error, 1=timeout, 2=failed) my $i; # counter my $dummy; ############################################################ ## MAIN main MAIN main MAIN main MAIN main MAIN main MAIN ## ############################################################ # # Read. # #$primary_server = <STDIN>; #$primary_server =~ s/\n//; # # Read the input line from STDIN. # $line = <STDIN>; $line =~ s/\n//; $mtid = substr( $line, 0, 4 ); $reqsize = 4; $bits = substr( $line, 4, 1 ); if ($bits eq "1") { $bitsize = 128; $reqsize += 16; } else { $bitsize = 64; $reqsize += 8; } $bits = substr( $line, 4, $bitsize ); $data = substr( $line, 4 + $bitsize ); $reqsize += length( $data ); $request = pack( "n", $reqsize ); $request .= $mtid; $request .= pack( 'B*', $bits ); $request .= $data; print STDOUT $request;

Note that this is still a work in progress and several pieces - including the communications and response - have not been coded, yet. I'm just trying to see if I can get this to work for building binary data.


In reply to Re^4: Help with pack error by taack
in thread Help with pack error by taack

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.