Hi
perlNinny,
I agree with imp that there may likely be some strange data in that line.
Here's a subroutine you could use to look at the line in question:
#
# decode_string: display the ascii value of each character of a stri
+ng
#
# In: $1 ... the string the decode
# $2 ... (optional) number of characters to show per line
# $3 ... (optional) a flag: nonzero = hilight non-printing c
+hars
# $4 ... (optional) a flag: 0 = show hex, nonzero = show dec
+imal
# $5 ... (optional) the symbol representing non-printing char
+s
#
# Result: Displays the value of each ascii character in the string,
# with a summary of the string length, including number of
# printable and non-printable characters.
#
sub decode_string {
my ($str, $nper, $b_hi, $b_dec, $nonasc) = @_;
# Defaults
$b_dec ||= 0;
$nper ||= ($b_dec? 12: 16);
$nonasc ||= '.';
$b_hi ||= 0;
# Anonoymous subroutines
my $pprintable = sub { ($_[0] < 32 || $_[0] > 126)? 0: 1 };
my $pshow_asc = sub {
my ($idx, $pchars, $width) = @_;
return unless @$pchars;
$idx and map { print " " x (3 + $width) } ($idx .. $nper-1);
print " [";
map { printf "%s", $pprintable->(ord $_)? $_: $nonasc } @$pcha
+rs;
print "]";
@$pchars = ( );
};
# Variable initialization
my ($pasc, $idx, $ntext, $nnontext) = ([ ], 0, 0, 0);
my $hilight = $b_hi? "\e[101m": "";
# Display the string
print "-" x 79;
my $len = length($str);
foreach my $i (0 .. $len-1) {
($i % $nper) or $pshow_asc->($i, $pasc, $b_dec);
($i % $nper) or printf "\n %7d|", $i;
push @$pasc, my $char = substr($str, $i, 1);
my $hlchar = "";
if ($pprintable->(ord $char)) {
++$ntext;
} else {
++$nnontext;
$hlchar = $hilight;
}
printf $b_dec? " $hlchar%3d\e[m": " $hlchar%02x\e[m", ord $cha
+r;
}
# Summary
$pshow_asc->($len % $nper, $pasc, $b_dec);
print "\n\n String length = $len ";
print "($ntext printable, $nnontext non-printable)\n", "-" x 79, "
+\n";
}
Try calling decode_string($string, 0, 1), where $string is the line you want to look at, and it should hilight (in red) any bytes in the line which are non-printable.
Sleeping even 1 second will take 40 minutes to run through the 2400 items.
It's a good point. But you could slow things less abruptly with something like:
select(undef, undef, undef, 0.05);
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.