Data::Binary(3pm)

Data::Binary3pm

Simple detection of binary versus text in strings

Usage

 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"

Overview

This simple module provides string equivalents to the -T / -B operators. Since these only work on file names and file handles, this module provides the same functions but on strings.

Note that 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 in -T, but applies them to a string. Returns true if the string is basically text.

is_binary($string)

Uses the same kind of heuristics in -B, but applies them to a string. Returns true if the string is basically binary.

Releases

4 releases since Debian 10 (Buster); the text changed 2 times.

  1. 10
  2. 11
  3. 12–13

Author

Stuart Watt, [email protected]

From libdata-binary-perl 0.01-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.