Data::Binary(3pm)

πŸ“¦
version 0.01 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Data::Binary πŸ’–

okay bestie, so Data::Binary is a lil Perl module (from the User Contributed Perl Documentation crew, iykyk) that does exactly one iconic thing: it tells you whether a string is text or binary. that's it. that's the whole vibe. periodt. πŸ’…


✨ NAME ✨

Data::Binary β€” Simple detection of binary versus text in strings πŸ¦‹


🌸 SYNOPSIS 🌸

use Data::Binary qw(is_text is_binary);
my $text = File::Slurp::read_file("test1.doc");
my $is_text = is_text($text); # equivalent to -T "test1.doc"
my $is_binary = is_binary($text); # equivalent to -B "test1.doc"

like yes bestie, you literally use it, you pull in is_text and is_binary, you slurp a file with File::Slurp::read_file, and you vibe-check that string. no cap. πŸ”₯


πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea β˜• β€” this simple module gives you string equivalents to the -T / -B operators. the way that -T and -B only work on file names and file handles? rude. so this module provides the same functions, but for strings instead. obsessed. 🫢

ngl, heads up bestie: the actual implementation is currently different, basically because the -T / -B functions are in C/XS, and this module is written in pure Perl. for now, anyway. πŸ™ˆ

πŸ’… FUNCTIONS πŸ’…

🌈 is_text($string)

uses the same kind of heuristics as -T, but applies them to a string. returns true if the string is basically text. slay. ✨

🧚 is_binary($string)

uses the same kind of heuristics as -B, but applies them to a string. returns true if the string is basically binary. iconic. πŸ’œ


πŸŽ€ AUTHOR πŸŽ€

Stuart Watt, stuart@morungos.com β€” king behavior honestly πŸ‘‘


Copyright (c) 2014 Stuart Watt. All rights reserved. πŸ“


and that's the whole page bestie, no crumbs left πŸ’€ β€” this was Data::Binary(3pm), rocking with perl v5.36.0, dated 2022-12-04. go forth and detect those binaries, main character 🌟🌸