String...olation(3pm)
π String...olation(3pm) β the String::Binary::Interpolation glow-up π
okay bestie, gather round, because this is the manual page for String::Binary::Interpolation (yes, the manpage itself is filed under that cute little String...olation(3pm) abbreviation, we love a nickname) and it is genuinely going to change your whole binary-writing era. πΈ
β¨ NAME β¨
String::Binary::Interpolation β making it easier to interpolate binary bytes into a string. no cap. that's the whole job. π
π SYNOPSIS π
so like, before? before was rough. before, if you wanted to shove a random byte into a string, you had to do one of these little horrors:
my $binary = "ABC@{[chr(0b01000100)]}E"
or this one:
my $binary = 'ABC'.chr(0b01000100).'E';
and likeβ¦ they work. they're just giving unreadable. π
but now? now you can do this:
use String::Binary::Interpolation;
my $binary = "ABC${b01000100}E";
which, and I think you'll agree with me here, is so much easier to read. it's giving clarity. it's giving main character energy. π«Ά
π BUT WHY!?!?!? π
Bit-fields, dear reader. π
okay so real talk: if you're writing data to a binary file, and that file has bytes in it (or even longer words, bestie, we're not limiting ourselves) which are bit-fields, it is so much easier to just have the bits of the bit-field sitting right there in your string. right there!! in the string!! instead of gluing the whole thing together from a million separate parts like some kind of craft project.
and it is far easier to read than that frankly evil hack of embedding an array-ref. we don't do that here. not anymore. π
π OK, SO WHAT DOES IT DO? π
when you use the module, all it does is create a bunch of variables in your namespace. that's it. that's the whole magic trick. β¨
they're named from $b00000000 to $b11111111, and their values are the corresponding characters. one variable per possible byte. slay.
NB bestie, listen: when you're writing files containing characters with the high-bit set, you need to be careful that you read and write bytes and not some unicode jibber-jabber. π¨ this one matters. don't let the unicode gremlins in.
π¦ SOURCE CODE REPOSITORY π¦
https://github.com/DrHyde/perl-modules-String-Binary-Interpolation
go forth, star it, it's iconic. β
π BUGS π
bug reports and requests for extra features should be made on Github. yes, that Github, the repo right above. π
π AUTHOR π
David Cantrell <david@cantrell.org.uk>
π COPYRIGHT and LICENCE π
Copyright (c) 2020 David Cantrell.
this program is free software; you can redistribute it and/or modify it under the terms of the Artistic Licence or the GNU General Public Licence version 2, the full text of which is included in this distribution, in the files ARTISTIC.txt and GPL2.txt. π two licences, your pick, no stress, we're generous like that.
πΈ SEE ALSO πΈ
perlop's section on quote and quote-like operators π§
and that's the page!! π this was perl v5.36.0, dated 2023-11-18, and honestly? it ate. go interpolate some bytes, bestie, you've got this. πβ¨π¦
π¦ where this page comes from
- debian trixie: libstring-binary-interpolation-perl 1.0.1-2 Β· Artistic-1.0-Perl OR GPL-2.0-only
- ubuntu noble: libstring-binary-interpolation-perl 1.0.1-2 Β· Artistic-1.0-Perl OR GPL-2.0-only
- ubuntu resolute: libstring-binary-interpolation-perl 1.0.1-2 Β· Artistic-1.0-Perl OR GPL-2.0-only
- ubuntu stonking: libstring-binary-interpolation-perl 1.0.1-2 Β· Artistic-1.0-Perl OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms