You can certainly edit binary data in perl, and there are a number of ways to do it. I'll assume you know all about the vagaries of differences in binary data structures between CPU architectures, so I won't open that particular can of worms.
Anyway, it works for me. If you show the code, we may be able to tell you the problem. Here's how I tested it:
$ cat binary_snr.pl #!/usr/bin/perl use strict; use warnings; my $binstr = join("", map { chr($_) } 0 .. 20); my $search_1 = join("", map { chr($_) } 7 .. 11); my $repl_1 = join("", map { 'A' } 7 .. 11); if ($binstr =~ s/$search_1/$repl_1/) { print "Fixed first one\n"; } print join(" ", map { ord($_) < 32 ? sprintf "0x%02x", ord($_) : $_ } split /|/, $binstr), "\n"; $ perl binary_snr.pl Fixed first one 0x00 0x01 0x02 0x03 0x04 0x05 0x06 A A A A A 0x0c 0x0d 0x0e 0x0f 0x10 +0x11 0x12 0x13 0x14 $
...roboticus
When your only tool is a hammer, all problems look like your thumb.
Update: minor text update to "If you show" sentence.
In reply to Re: binary search/replace
by roboticus
in thread binary search/replace
by momo33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |