in reply to Add 1 to an arbitrary-length binary string
Here's a guess ...
#!/usr/bin/perl use strict; # https://www.perlmonks.org/?node_id=11155633 use warnings; use Data::Dump 'dd'; for ( 'aa', "a\xff", 'frequency/is/measured/in/hertz' ) { dd 'in', $_; my $onelarger = s/([^\xff])\xff*\z/ $1 =~ tr||\x01-\xff|cr /er; dd 'out', $onelarger; }
Outputs:
("in", "aa") ("out", "ab") ("in", "a\xFF") ("out", "b") ("in", "frequency/is/measured/in/hertz") ("out", "frequency/is/measured/in/hert{")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Add 1 to an arbitrary-length binary string
by ikegami (Patriarch) on Nov 16, 2023 at 01:56 UTC | |
by tybalt89 (Monsignor) on Nov 16, 2023 at 02:35 UTC | |
by syphilis (Archbishop) on Nov 16, 2023 at 06:53 UTC | |
by ikegami (Patriarch) on Nov 16, 2023 at 05:36 UTC | |
by einhverfr (Friar) on Nov 16, 2023 at 02:44 UTC | |
|
Re^2: Add 1 to an arbitrary-length binary string
by einhverfr (Friar) on Nov 16, 2023 at 02:24 UTC |