Devel::StringInfo(3)
π¦ Devel::StringInfo β the manual page, but make it make sense π¦
okay bestie, so this is a User Contributed Perl Documentation page for Devel::StringInfo(3). It's a debugging aid. It's giving detective energy. Let's get into it π
β¨ NAME β¨
Devel::StringInfo β gather information about strings. that's it, that's the whole vibe. it's the "what even IS this string" module π
πΈ SYNOPSIS πΈ
my $string = get_string_from_somewhere();
use Devel::StringInfo qw(string_info);
# warn()s a YAML dump in void context
string_info($string);
# the above is actually shorthand for:
Devel::StringInfo->new->dump_info($string);
# you can also customize with options:
my $d = Devel::StringInfo->new(
guess_encoding => 0,
);
# and collect data instead of formatting it as a string
my %hash = $d->gather_data( $string );
warn "it's a utf8 string" if $hash{is_utf8};
so you can just call string_info($string) and let it warn at you, but under the hood that's literally the same as Devel::StringInfo->new->dump_info($string) β it's the shorthand, iykyk. and if you want to be extra (affectionate) you pass options to new, or grab the raw data with gather_data and check $hash{is_utf8} yourself like the main character you are π₯
π DESCRIPTION π
This module is a debugging aid that helps figure out more information about strings. it's your little investigative bestie π΅οΈβοΈ
so here's the tea: Perl has two main "types" of strings, and you will get confused about which one you're holding.
- unicode strings β where
utf8::is_utf8returns true β¨ - octet strings β just a bunch of bytes, no thoughts, head empty π
Depending on the source of the data, what data it interacted with, as well as the fact that Perl may implicitly upgrade octet streams which represent strings in the native encoding to unicode strings, it's sometimes genuinely hard to know what exactly is going on with a string. not me getting gaslit by my own scalar π
This module clumps together a bunch of checks you can perform on a string to figure out what's in it. one call, all the lore. periodt π
π EXPORTS π
This module optionally exports a string_info subroutine. It uses Sub::Exporter, so you can pass any options to the import routine, and they will be used to construct the dumper for your exported sub:
use Devel::StringInfo string_info => { guess_encoding => 0 };
yes, the options you pass at use time become the default vibe of your exported sub. iconic π«Ά
β ATTRIBUTES β
guess_encodingβ Whether or not to useEncode::Guessto guess the encoding of the data if it's not a unicode string. let it play detective, or don't πencoding_suspectsβ The list of suspect encodings. SeeEncode::Guess. Defaults to the empty list, which is a special case forEncode::Guess. so like, no suspects named meansEncode::Guessdoes its special thing. slay π΅οΈinclude_value_infoβ Include some information about the string value (does it contain0x00chars, is it alphanumeric, does it have newlines, etc). the little gossipy details about your string πinclude_decodedβ Whether to include a recursive dump of the decoded versions of a non unicode string. go deeper. inception but for encodings πinclude_hexβ Whether to include aData::HexDump::XXDdump indump_info. hex girlies rise πinclude_rawβ Whether to include a simple interpolation of the string indump_info. raw and unfiltered, no escaping, just vibes π
π METHODS π
dump_info $string, %extra_fields
Use YAML to dump information about $string. yep, YAML. we love a structured format β¨
In void context it prints, in other contexts it returns the dump string. so know where you're calling it or you'll be out here wondering why nothing came back π
If include_raw is set then a "raw" version (no escaping of the string) is appended with some boundry markings. This can help understand what's going on if YAML's escaping is confusing. honestly? yeah. YAML escaping will humble you.
If include_hex is set then Data::HexDump::XXD will be required and used to dump the value as well. so that module gets pulled in on demand, no cap π₯
gather_data $string, %opts
Gathers information about the string. the collector behavior, we stan πΈ
Calls various other gather_ methods internally.
Used by dump_info to dump the results. so dump_info is basically gather_data + a glow-up π
In scalar context returns a hash reference, in list context key value pairs. know your context bestie, it changes everything.
All hash references are tied to Tie::IxHash in order to be laid out logically in the dump. so the ordering stays cute and sensible instead of randomized chaos π
%opts is not yet used but may be in the future. it's reserved. it's waiting for its moment. main character arc pending π
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org>
π COPYRIGHT & LICENSE π
Copyright (c) 2007 Yuval Kogman. All rights reserved
This program is free software; you can redistribute it and/or modify it
under the terms of the MIT license or the same terms as Perl itself.
okay so that's the whole page. this was documented by the fine people doing User Contributed Perl Documentation, running on perl v5.42.0, dated 2025-07-25. go forth and figure out what your strings are actually doing, bestie πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-Devel-StringInfo 0.04-37.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl OR MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms