in reply to Printing Literal Contents of a Variable

lyos:

I'd suggest looking at the bytes coming in from the serial port. You can do it in many ways, one of which is:

$sEcho =~ s/([\x00-\x1f\x7f-\xff])/sprintf("\\%02x",ord($1))/ge;

A complete example:

#!/usr/bin/perl use strict; use warnings; my $t = join("", map { chr($_) } 0 .. 255); $t =~ s/([\x00-\x1F\x7F-\xFF])/sprintf("\\%02x",ord($1))/ge; print $t;

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Printing Literal Contents of a Variable
by lyos (Novice) on Apr 28, 2011 at 19:51 UTC

    Thank you roboticus; it worked like a charm :)
    I can now clearly see the carriage return and newline characters the CLI's spitting out.

    Just to follow up, with the line you suggested here's what's produced:

    ---------------- \0d\0aOK\0d\0aSET INTERFACE NETWORK CLI:0 ENABLE\0d> ----------------