1SQL::Translator::Utils(U3s)er Contributed Perl DocumentatSiQoLn::Translator::Utils(3)
2
3
4

NAME

6       SQL::Translator::Utils - SQL::Translator Utility functions
7

SYNOPSIS

9         use SQL::Translator::Utils qw(debug);
10         debug("PKG: Bad things happened");
11

DESCSIPTION

13       "SQL::Translator::Utils" contains utility functions designed to be used
14       from the other modules within the "SQL::Translator" modules.
15
16       Nothing is exported by default.
17

EXPORTED FUNCTIONS AND CONSTANTS

19       debug
20
21       "debug" takes 0 or more messages, which will be sent to STDERR using
22       "warn".  Occurances of the strings PKG, SUB, and LINE will be replaced
23       by the calling package, subroutine, and line number, respectively, as
24       reported by caller(1).
25
26       For example, from within "foo" in SQL/Translator.pm, at line 666:
27
28         debug("PKG: Error reading file at SUB/LINE");
29
30       Will warn
31
32         [SQL::Translator: Error reading file at foo/666]
33
34       The entire message is enclosed within "[" and "]" for visual clarity
35       when STDERR is intermixed with STDOUT.
36
37       normalize_name
38
39       "normalize_name" takes a string and ensures that it is suitable for use
40       as an identifier.  This means: ensure that it starts with a letter or
41       underscore, and that the rest of the string consists of only letters,
42       numbers, and underscores.  A string that begins with something other
43       than [a-zA-Z] will be prefixer with an underscore, and all other char‐
44       acters in the string will be replaced with underscores.  Finally, a
45       trailing underscore will be removed, because that's ugly.
46
47         normalize_name("Hello, world");
48
49       Produces:
50
51         Hello_world
52
53       A more useful example, from the "SQL::Translator::Parser::Excel" test
54       suite:
55
56         normalize_name("silly field (with random characters)");
57
58       returns:
59
60         silly_field_with_random_characters
61
62       header_comment
63
64       Create the header comment.  Takes 1 mandatory argument (the producer
65       classname), an optional comment character (defaults to $DEFAULT_COM‐
66       MENT), and 0 or more additional comments, which will be appended to the
67       header, prefixed with the comment character.  If additional comments
68       are provided, then a comment string must be provided ($DEFAULT_COMMENT
69       is exported for this use).  For example, this:
70
71         package My::Producer;
72
73         use SQL::Translator::Utils qw(header_comment $DEFAULT_COMMENT);
74
75         print header_comment(__PACKAGE__,
76                              $DEFAULT_COMMENT,
77                              "Hi mom!");
78
79       produces:
80
81         --
82         -- Created by My::Prodcuer
83         -- Created on Fri Apr 25 06:56:02 2003
84         --
85         -- Hi mom!
86         --
87
88       Note the gratuitous spacing.
89
90       parse_list_arg
91
92       Takes a string, list or arrayref (all of which could contain comma-sep‐
93       arated values) and returns an array reference of the values.  All of
94       the following will return equivalent values:
95
96         parse_list_arg('id');
97         parse_list_arg('id', 'name');
98         parse_list_arg( 'id, name' );
99         parse_list_arg( [ 'id', 'name' ] );
100         parse_list_arg( qw[ id name ] );
101
102       $DEFAULT_COMMENT
103
104       This is the default comment string, '-- ' by default.  Useful for
105       "header_comment".
106

AUTHORS

108       Darren Chamberlain <darren@cpan.org>, Ken Y. Clark <kclark@cpan.org>.
109
110
111
112perl v5.8.8                       2007-10-24         SQL::Translator::Utils(3)
Impressum