1File::Type::Builder(3)User Contributed Perl DocumentationFile::Type::Builder(3)
2
3
4

NAME

6       File::Type::Builder - parse mime-magic and generate code
7

SYNOPSIS

9           my $build = File::Type::Builder->new();
10
11           while (<magic>) {
12             chomp;
13             my $parsed = $build->parse_magic($_);
14
15             my $code   = $build->string_start($parsed);
16             (or string_offset or beshort)
17           }
18

DESCRIPTION

20       Reads in the mime-magic file format and translates it to code.  (This
21       documentation would be longer if I really expected anyone other than me
22       to run the code.)
23

METHODS

25   new
26       Creates a new File::Type::Builder object.
27
28   parse_magic
29       Pulls apart a line of a mime-magic file using a string of regular
30       expressions.
31
32       An example mime-magic file can be found in cleancode CVS at
33       <http://cleancode.org/cgi-bin/viewcvs.cgi/email/mime-magic.mime?rev=1.1.1.1>
34
35   string
36       Builds code to match magic that's of type string.
37
38       Has to do some cleverness to make the regular expression work properly.
39
40   be
41       Builds code to match 'beshort' and 'belong' magic (eg audio/mpeg,
42       image/jpeg).
43

PRIVATE METHODS

45   _substr_matching
46       Sometimes the data is smaller than the offset we're looking for in the
47       file. If this is the case, then the file is obviously not of that type,
48       and furthermore we should avoid issuing a couple of warnings that Perl
49       would otherwise emit.
50
51       This subroutine generates this code.
52
53   _get_escapes
54       Returns a reference to a hash defining characters that should not be
55       escaped.
56

TODO

58           * Add handlers for other magic types (bedate, byte, etc)
59
60           * Make verbosity/logging nicer.
61
62           * Find more edge cases.
63
64           * Remove redundant 'if (length $data > 0)' check.
65
66       Longer term:
67
68           * Fix for multiple magic format types?
69

BUGS

71       Incomplete. Some known issues with odd entries in mime-magic. Skips
72       some mime-magic lines.
73

SEE ALSO

75       File::Type, which is partially generated by this module.
76

AUTHOR

78       Paul Mison <pmison@fotango.com>
79
81       Copyright 2003 Fotango Ltd.
82

LICENSE

84       Licensed under the same terms as Perl itself.
85
86
87
88perl v5.30.1                      2020-01-30            File::Type::Builder(3)
Impressum