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

PRIVATE METHODS

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

TODO

65           * Add handlers for other magic types (bedate, byte, etc)
66
67           * Make verbosity/logging nicer.
68
69           * Find more edge cases.
70
71           * Remove redundant 'if (length $data > 0)' check.
72
73       Longer term:
74
75           * Fix for multiple magic format types?
76

BUGS

78       Incomplete. Some known issues with odd entries in mime-magic. Skips
79       some mime-magic lines.
80

SEE ALSO

82       File::Type, which is partially generated by this module.
83

AUTHOR

85       Paul Mison <pmison@fotango.com>
86
88       Copyright 2003 Fotango Ltd.
89

LICENSE

91       Licensed under the same terms as Perl itself.
92
93
94
95perl v5.8.8                       2007-04-17            File::Type::Builder(3)
Impressum