• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DrHyde / perl-modules-String-Binary-Interpolation / 8913307440

01 May 2024 06:26PM UTC coverage: 100.0%. Remained the same
8913307440

Pull #20

github

web-flow
Bump cross-platform-actions/action from 0.23.0 to 0.24.0

Bumps [cross-platform-actions/action](https://github.com/cross-platform-actions/action) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/cross-platform-actions/action/releases)
- [Changelog](https://github.com/cross-platform-actions/action/blob/master/changelog.md)
- [Commits](https://github.com/cross-platform-actions/action/compare/v0.23.0...v0.24.0)

---
updated-dependencies:
- dependency-name: cross-platform-actions/action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #20: Bump cross-platform-actions/action from 0.23.0 to 0.24.0

6 of 6 relevant lines covered (100.0%)

43.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/String/Binary/Interpolation.pm
1
package String::Binary::Interpolation;
2

3
use strict;
1✔
4
use warnings;
1✔
5

6
# Yuck, semver. I give in, the stupid cult that doesn't understand
7
# what the *number* bit of *version number* means has won.
8
our $VERSION = '1.0.1';
9

10
sub import {
11
    my $victim = (caller(0))[0];
1✔
12
    foreach my $byte (0 .. 255) {
1✔
13
        no strict 'refs';
1✔
14
        *{sprintf('%s::b%08b', $victim, $byte)} = \chr($byte);
256✔
15
    }
16
}
17

18
1;
19

20
=head1 NAME
21

22
String::Binary::Interpolation - make it easier to interpolate binary bytes into a string
23

24
=head1 SYNOPSIS
25

26
Where you would previously have had to write something like this ...
27

28
    my $binary = "ABC@{[chr(0b01000100)]}E"
29

30
or ...
31

32
    my $binary = 'ABC'.chr(0b01000100).'E';
33

34
to interpolate some random byte into a string you can now do this ...
35

36
    use String::Binary::Interpolation;
37

38
    my $binary = "ABC${b01000100}E";
39

40
which I think you'll agree is much easier to read.
41

42
=head1 BUT WHY!?!?!?
43

44
Bit-fields, dear reader. If you are writing data to a binary file, and that
45
file contains bytes (or even longer words) which are bit-fields, it is easier
46
to have the bits of the bit-field right there in your string instead of having
47
to glue the string together from various parts, and it's far easier to read
48
than the frankly evil hack of embedding an array-ref.
49

50
=head1 OK, SO WHAT DOES IT DO?
51

52
When you C<use> the module all it does is create a bunch of varliables in
53
your namespace. They are named from C<$b00000000> to C<$b11111111> and their
54
values are the corresponding characters. NB that when writing files containing
55
characters with the high-bit set you need to be careful that you read and write
56
B<bytes> and not some unicode jibber-jabber.
57

58
=head1 SOURCE CODE REPOSITORY
59

60
L<https://github.com/DrHyde/perl-modules-String-Binary-Interpolation>
61

62
=head1 BUGS
63

64
Bug reports and requests for extra features should be made on Github.
65

66
=head1 AUTHOR
67

68
David Cantrell E<lt>david@cantrell.org.ukE<gt>
69

70
=head1 COPYRIGHT and LICENCE
71

72
Copyright (c) 2020 David Cantrell. This program is free software; you can
73
redistribute it and/or modify it under the terms of the Artistic Licence
74
or the GNU General Public Licence version 2, the full text of which is
75
included in this distribution, in the files ARTISTIC.txt and GPL2.txt.
76

77
=head1 SEE ALSO
78

79
L<perlop>'s section on quote and quote-like operators
80

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc