GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Binary(3) User Contributed Perl Documentation Data::Binary(3)

Data::Binary - Simple detection of binary versus text in strings

 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"

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.

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

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

Stuart Watt, stuart@morungos.com

Copyright (c) 2014 Stuart Watt. All rights reserved.
2014-03-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.