Rob Dixon wrote:

> R. Joseph Newton wrote:
> >
> > Maybe you should do a binary/text dump of the file.  Chose a set of meanguful
> > printing characters to print as character, printi anything outside of this range
> > as hex.  Something like:
>
> I like that: 'meanguful'. I shall have to try to fir it into my conversation :)
>
> > open IN, 'hello.obj' or die "Couldn't open damnfool file: $!";
> > binmode IN;
> > local $/;
> >
> > my $whole_durn_thang = <IN>;
> > my @chars = split //, $whole_durn_thang;
> > my $alphabetic = 0;
> > foreach $char (@chars) {
> >    if ($char =~ /[EMAIL PROTECTED]&*()_+ ,]/) {
> >       print "\n" unless $alphabetic;
> >       print $char;
> >       $alphabetic = 1;
> >    } else {
> >       print "\n" if $alphabetic;
> >       printf "%02x    ", ord $char,
> >       $alphabetic = 0;
> >    }
> > }
>
> Hi Joseph. Do you really mean this? What about these?
>
>   " $ % ' - . / : ; < = > ? [ \ ] ` { | }
>
> I would code
>
>   if ($char =~ /[[:graph:]]/) {
>     :
>   }
>
> which chooses everything that's visible on-screen.
>
> [snip]
>
> Rob

Sounds even better.  My guess is that the OP will need only a small subset, if any, of
printing characters outside of the alphanmeric, though.  The character class certainly
makes for neater expression.  I'm not really shooting for elegant expression here,
though.  This is meant as a Q&D probe just to get a sampling of what hidden chars
might be mucking up the works.  It is pretty much intended to be used in transit, then
thrown away.

I hope the OP didn't draw the conclusion that this was what you do for keeper code.  I
thought that I had uderscored that point when I said that this was only intended for
the ad-hoc task.  All I'm really trying to do gere is to isolate the bulk of the plain
text content, so the few troublesome control characters stand out more distinctly.
Why waste time with a scalpel when a splitting maul will do?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to