CSV

read CSV

write CSV

    use Text::CSV_XS qw[];

    Text::CSV_XS::csv(
        out         => 'filename.csv',
        in          => Array[HashRef],
        headers     => [qw[field1 field2 ...]],
        binary      => 1,
        encoding    => 'UTF-8',
        decode_utf8 => 0,
        eol         => $LF,
    );

PostgreSQL

uuid

https://www.postgresql.org/docs/current/static/uuid-ossp.html

        CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

        "id" UUID PRIMARY KEY NOT NULL

MySQL

connect

    my $dbh = DBI->connect(
        qq[DBI:mysql:database=$self->{cfg}->{MYSQL}->{db};host=$self->{cfg}->{MYSQL}->{host};port=$self->{cfg}->{MYSQL}->{port}],
        $self->{cfg}->{MYSQL}->{username},
        $self->{cfg}->{MYSQL}->{password},
        {   RaiseError             => 1,
            PrintWarn              => 0,
            ShowErrorStatement     => 1,
            mysql_auto_reconnect   => 1,
            mysql_enable_utf8mb4   => 1,
            mysql_multi_statements => 1,
        }
    );

create table

    CREATE TABLE IF NOT EXISTS `table` (
        `id` VARCHAR(20) NOT NULL,
        PRIMARY KEY (`player_id`)
    ) DEFAULT CHARSET=utf8mb4;

SQLite

field with the current unix timestamp by default

    "unix_timestamp" INTEGER NOT NULL DEFAULT(CAST(STRFTIME('%s', 'now') AS INT))

Other

perl tail recursion

    @_ = ($arg1, $arg2, ...);

    goto &method;