Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Binary buffer - substr

by 7stud (Deacon)
on Jan 14, 2013 at 06:21 UTC ( #1013160=note: print w/replies, xml ) Need Help??


in reply to Binary buffer - substr

Binary data can contain newline characters, which cannot be matched by the default dot in a regex.
use strict; use warnings; use 5.012; my $str = "\x16-\x03\x01\x01-\x16\x03\x01\x01PAY\nLOAD"; if ($str =~ /(\x16\x03\x01\x01 .*)/xms) { say $1; printf "%vd \n", $1; say length($str) - length($1); } --output:-- PAY LOAD 22.3.1.1.80.65.89.10.76.79.65.68 6

Replies are listed 'Best First'.
Re^2: Binary buffer - substr
by dave_the_m (Prior) on Jan 14, 2013 at 08:26 UTC
    Binary data can contain newline characters, which cannot be matched by the default dot in a regex
    Good point. I've updated my original post to include /s

    Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013160]
help
Chatterbox?
[Discipulus]: even with odd number of \
[Eily]: well, it allows you to concatenate strings to make a path without knowing if the final \ is already there or not

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-05-24 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?