in reply to Matching a hex value in a string...

hex '0a' returns the number 10 (= 0x0a). To turn that into character 10, use chr(hex('0a')). But using the \x escape is easier: split /\x0a/. Which is identical to split /\n/, since your special character is just a newline.
  • Comment on Re: Matching a hex value in a string...

Replies are listed 'Best First'.
Re^2: Matching a hex value in a string...
by moritz (Cardinal) on Feb 27, 2008 at 11:43 UTC
    ... but on Windows "\n" is the same as "\r\x0A", isn't it?

    Or am I completely wrong here? (no windows perl installed, can't test it :()

      No. \n is \x0A on Windows. (And $/ is \n, since the CRLF→LF conversion occurs before the buffer is searched for the IRS.)

      >perl -e"print length qq{\n} 1 >perl -e"print qq{\n} eq qq{\x0A} ?1:0 1 >perl -e"print $/ eq qq{\x0A} ?1:0 1 >echo foo| perl -e"print length <> 4

      Maybe you're thinking of older Macs, where \n is \x0D.

      Update: Added proof.