1Padre::Util(3) User Contributed Perl Documentation Padre::Util(3)
2
3
4
6 Padre::Util - Padre non-Wx Utility Functions
7
9 The "Padre::Util" package is a internal storage area for miscellaneous
10 functions that aren't really Padre-specific that we want to throw
11 somewhere convenient so they won't clog up task-specific packages.
12
13 All functions are exportable and documented for maintenance purposes,
14 but except for in the Padre core distribution you are discouraged in
15 the strongest possible terms from using these functions, as they may be
16 moved, removed or changed at any time without notice.
17
19 "slurp"
20 my $content = Padre::Util::slurp( $file );
21 if ( $content ) {
22 print $$content;
23 } else {
24 # Handle errors appropriately
25 }
26
27 This is a simple slurp implementation, provided as a convenience for
28 internal Padre use when loading trivial unimportant files for which we
29 don't need anything more robust.
30
31 All file reading is done with "binmode" enabled, and data is returned
32 by reference to avoid needless copying.
33
34 Returns the content of the file as a SCALAR reference if the file
35 exists and can be read.
36
37 Returns false if loading of the file failed.
38
39 This function is only expected to be used in situations where the file
40 should almost always exist, and thus the reason why reading the file
41 failed isn't really important.
42
43 "newline_type"
44 my $type = Padre::Util::newline_type( $string );
45
46 Returns "None" if there was not "CR" or "LF" in the file.
47
48 Returns "UNIX", "Mac" or "Windows" if only the appropriate newlines
49 were found.
50
51 Returns "Mixed" if line endings are mixed.
52
53 "parse_variable"
54 my $version = Padre::Util::parse_variable($file, 'VERSION');
55
56 Parse a $file and return what $VERSION (or some other variable) is set
57 to by the first assignment.
58
59 It will return the string "undef" if it can't figure out what $VERSION
60 is. $VERSION should be for all to see, so "our $VERSION" or plain
61 $VERSION are okay, but "my $VERSION" is not.
62
63 "parse_variable()" will try to "use version" before checking for
64 $VERSION so the following will work.
65
66 $VERSION = qv(1.2.3);
67
68 Originally based on "parse_version" from ExtUtils::MakeMaker.
69
70 "get_matches"
71 Parameters:
72
73 · The text in which we need to search
74
75 · The regular expression
76
77 · The offset within the text where we the last match started so the
78 next forward match must start after this.
79
80 · The offset within the text where we the last match ended so the
81 next backward match must end before this.
82
83 · backward bit (1 = search backward, 0 = search forward) - Optional.
84 Defaults to 0.
85
86 "_T"
87 The "_T" function is used for strings that you do not want to translate
88 immediately, but you will be translating later (multiple times).
89
90 The only reason this function needs to exist at all is so that the
91 translation tools can identify the string it refers to as something
92 that needs to be translated.
93
94 Functionally, this function is just a direct pass-through with no
95 effect.
96
97 "share"
98 If called without a parameter returns the share directory of Padre. If
99 called with a parameter (e.g. "Perl6") returns the share directory of
100 Padre::Plugin::Perl6. Uses File::ShareDir inside.
101
103 Copyright 2008-2011 The Padre development team as listed in Padre.pm.
104
105 This program is free software; you can redistribute it and/or modify it
106 under the same terms as Perl itself.
107
108 The full text of the license can be found in the LICENSE file included
109 with this module.
110
111
112
113perl v5.30.0 2019-07-26 Padre::Util(3)