in reply to Re^3: Can't connect to data source 'DBI:SQLite:\C:\Users\DON\Desktop\data.db
in thread pp concatenate path

THANK YOU!

eliminating the "<:encoding(UTF-8)" solves the problem, even if I am not quite sure why. As my file is encoded in UTF8, how am I supposed to open it correctly and read it?

Just to complete the picture

This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x +86-multi-thread PAR Packager, version 1.043 (PAR version 1.015) DBD::SQLite is up to date (1.58)

Replies are listed 'Best First'.
Re^5: Can't connect to data source 'DBI:SQLite:\C:\Users\DON\Desktop\data.db
by Anonymous Monk on Apr 23, 2018 at 07:24 UTC

    even if I am not quite sure why. As my file is encoded in UTF8, how am I supposed to open it correctly and read it?

    What output does this program produce for you? After being packed with pp?

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; open my($fh),'<:encoding(UTF-8)', 'deleteme.txt' or die $!; my $file = <$fh>; close $fh; my $dsn = "dbi:SQLite:dbname=$file"; # extract dbi:driver prefix from $dsn into $1 $dsn =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i or '' =~ /()/; # ensure $1 etc are empty if match fails my $driver_attrib_spec = $2 || ''; # Set $driver. Old style driver, if specified, overrides new dsn style +. my $driver = $1 or die pp( $file, $dsn, [ $1, $2 ] ); dd( $file, $dsn, [ $1, $2 ] );