in reply to Searching for control characters

a) you don't check the return value of your open calls. 2) Perl is case sensitive; ORD is not ord. III) Your regex has no capturing parens so $1 won't contain anything.

Replies are listed 'Best First'.
Re^2: Searching for control characters
by ericdp (Novice) on Feb 07, 2006 at 20:48 UTC
    a) Yes, I did forget that. But it does work. For better style and conformity I should have it.
    b) Yes, I mispelled it here. but it is all caps in my script.
    c) Doesn't the parens around [:cntrl:] not capture? Or did I read that wrong in the docs?
    if ( $line =~ /([[:cntrl:]])/ ) { my $c = $1;
    Or should I have gone about this differently?
    Thanks. Eric

      Your code runs, but you have no idea that the open failed and you blithely continue on until you get the error about trying to print to an unopened handle.

      Next the translation: "Yes, I mispelled it here. but it is all caps (and still wrong) in my script." Again, ORD is not ord. CASE MATTERS.

      And that code there is different than your initial example (but yes, that's correct and should put something meaningful in $1).

      oops. ... dumb me ... "ord" not "ORD".