in reply to Re: string? Or binary garbage?
in thread string? Or binary garbage?

Given the expense of the application and that it has to ierate over thousands of images at a time, I don't want to look too far into other packages for heavy overhead. Now that I think of it, I just want to see if there are any unprintable control characters... Looking at the perldocs, I should be able to use

$a =~ /\p{IsC}/

...which says, "crazy control characters and such." However, that seems to be matching legitimate text in some cases. So, I try

$a !~ /\p{IsPrint}/

but that doesn't work either. Then I tried:

$a !~ /\p{IsASCII}/

but that's also not working. I can get into the details on why these things aren't working, but I keep thinking someone's going to pipe in with a statement like, "I ran into this ages ago, and here's a routine that finds all the exceptions..."

If not, I suppose I can elaborate on how this isn't working.

Replies are listed 'Best First'.
Re^3: string? Or binary garbage?
by argv (Pilgrim) on Dec 01, 2004 at 01:57 UTC
    Well, I fixed the problem myself. In my previous example, I had:

    $a !~ /\p{IsPrint}/

    which tests whether $a does NOT match any printing characters. (In other words, the test fails if it DOES match a PRINTABLE character.) So, what I wanted to do is close, but not quite the same thing:

    $a =~ /\P{IsPrint}/
    which basically tests "does $a match the compliment of a printing character?" In other words, "are there ANY non-printing characters here?"

    One has to look really closely and speak out the logic into a dark empty room before knowing intuitively which was the right choice ahead of time.

      could you use unpack to do this as well?

      i.e try and unpack some binary string data and see if it works ..