This is a filter plugin for Data::Printer that looks for binary strings with signatures from popular file
types. If one is detected, instead of the bogus binary dump it will print the content type and the string
size.
For example, let's say you've read an image file into $data, maybe from a user upload or from Imager or
ImageMagick. If you use Data::Printer with this filter, it will show you something like this:
my $data = get_image_content_from_somewhere();
use DDP; p $data; # (PNG Image, 32K)
hexdump
If, for whatever reason, you want to inspect the actual content of the binary data, you may set
"filter_contenttype.hexdump" to true. This will pretty-print your data in hexadecimal, similar to tools
like "hexdump". Once active, it will print the entire content, but you may limit the size by changing
"filter_contenttype.hexdump_size" to any value (unit == bytes), and you can even start from a different
position using "filter_contenttype.hexdump_offset". Set it to a negative value to make your offset
relative to the end to the data.
Finally, the default hexdump mode will not indent your content. Since it's a binary dump, we want to get
as much terminal space as we can. If you rather have the dump properly indented (relative to your current
dump indentation level), just set "filter_contenttype.hexdump_indent" to 1.
DetectedContent
Below are the signatures detected by this filter.
Images
• PNG
• JPEG
• GIF
• ICO
• TIFF
• BMP
Video
• AVI
• MPEG
Audio
• WAV
• MP3
• FLAC
• OGG
DocumentsandArchives
• ZIP
• GZIP
• BZIP2
• PDF
• Binary Executables (ELF and Win32)
We don't want this list to grow into a full-blown detection system, and instead just focus on common
types. So if you want to contribute with patches or open an issue for a missing type, please make sure
you actuallyhavedatastructureswiththatcontent (e.g. you were bit by this in your code and DDP
didn't help).
We want to help people debug code, not add content types just for the sake of it :)