SQLite::VirtualTable::Util - Helper functions for SQLite::VirtualTable


SQLite-VirtualTable documentation Contained in the SQLite-VirtualTable distribution.

Index


Code Index:

NAME

Top

SQLite::VirtualTable::Util - Helper functions for SQLite::VirtualTable

SYNOPSIS

Top

  use SQLite::VirtualTable::Utill qw(unescape);

  my $foo = unescape $bar;

DESCRIPTION

Top

This module contains some utility functions that are used by SQLite::VirtualTable and derived modules.

FUNCTIONS:

unescape($arg)

remove quotes and resolve escaped characters from the argument.

AUTHOR

Top

Salvador Fandiño (sfandino@yahoo.com).

COPYRIGHT AND LICENSE

Top


SQLite-VirtualTable documentation Contained in the SQLite-VirtualTable distribution.

package SQLite::VirtualTable::Util;

use strict;
use warnings;

our $VERSION = '0.03';

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT_OK = qw(unescape);

my %esc = ( "\n" => 'n',
	    "\r" => 'r',
	    "\t" => 't' );
my %unesc = reverse %esc;

sub unescape {
    my $s = shift;
    $s =~ s{\\([tnr\\"' =:#!])|\\u([\da-fA-F]{4})|["']}{
                                defined $1 ? $unesc{$1}||$1 :
                                defined $2 ? chr hex $2 :
                                '';
                      }ge;
    $s;
}


1;

__END__