in reply to Using regexp with binary data

The problem appears to be due to a numerical 10 within my data that is being interpreted as a line feed.

Take a look at the ASCII character table; a byte/character with a ordinal value of 10 is a linefeed (in most popular character encodings, at least). As mentioned above, using the /s modifier solves this problem.

If you're using this as a general technique, you should also be very careful that your @find array doesn't contain any other special characters like "(", or "[". Just because you write characters as escape sequences doesn't give them any special status: they're just characters.

Replies are listed 'Best First'.
Re^2: Using regexp with binary data
by fizbin (Chaplain) on Aug 28, 2005 at 15:54 UTC
    If you're using this as a general technique, you should also be very careful that your @find array doesn't contain any other special characters like "(", or "[". Just because you write characters as escape sequences doesn't give them any special status: they're just characters.
    Ah, but if he takes my suggestion and writes each expression as qr"\x...blah blah..."s, then those escape sequences do in fact make the characters unspecial, and he can use this technique with impunity. For example, to his original code add the expressions qr"\x06\x2E"s and "\x06\x2E" - the one inside qr will not match, since in it the \x2E is seen as a literal, whereas without qr you'll get the problem you're talking about. (For those of you without the ASCII table memorized, \x2E is .)

    For full details, see perlop, especially the section "Gory details of parsing quoted constructs".

    --
    @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/