The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SQL::Load::Util

SYNOPSIS

use SQL::Load::Util qw/
    name_list 
    parse
    remove_extension
    trim
/;

my $name_list = name_list('foo');

my %parse = (parse(SQL));

my $remove_extension = remove_extension('file.sql');

my $trim = trim('   baz   ');

DESCRIPTION

SQL::Load::Util contains useful methods to SQL::Load.

METHODS

name_list

# ['FindAll', 'find_all', 'find-all']
my $name_list = name_list('find_all');

returns an array or arrayref with three formats: CamelCase, snake_case and kebab-case.

parse

my $data = q{
    -- [find]
    SELECT * FROM foo WHERE id = ?;
    
    -- [find-all]
    SELECT * FROM foo ORDER BY id DESC;
};

# [
#   'find',
#   'SELECT * FROM foo WHERE id = ?;',
#   'find-all',
#   'SELECT * FROM foo ORDER BY id DESC;'
# ]
my $parse = parse($data);

returns an array or arrayref with name in the even position and SQL in the odd position.

remove_extension

# users
my $remove_extension = remove_extension('users.sql')

remove the extension .sql

trim

# foo
my $trim = trim('  foo   ');

remove spaces at the begin and end

SEE ALSO

SQL::Load.

AUTHOR

Lucas Tiago de Moraes, lucastiagodemoraes@gmail.com.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Lucas Tiago de Moraes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.