Windows 10, Strawberryperl 5.16.3, pp

If I pack the following two scripts with pp, the first work, the second not (Can't connect to data source 'DBI:SQLite:\C:\Users\DON\Desktop\data.db' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at script/myscript.pl). In the first, the database path is hard encoded, in the second it is read by a configuration file (in the example a simple text file). Note that both works nicely from command line

use warnings; use strict; use DBI; use DBD::SQLite; my $Path='C:\Users\DON\Desktop\data.db'; my $dsn = "DBI:SQLite:" . $Path; print "Connecting $dsn ... \n"; my %attr = (RaiseError => 1, sqlite_unicode => 1, AutoCommit = +> 1); my $dbh = DBI->connect($dsn, "", "", \%attr) || die $DBI::errs +tr; print "done!\n";

And here the second script, reading the same $Path value from file

use warnings; use strict; use DBI; use DBD::SQLite; my $Path; print "Reading configuration file...\n"; my $FileInput="config.txt";#simple txt file containing this: C +:\Users\DON\Desktop\data.db open my $FH, "<:encoding(UTF-8)", $FileInput; while (my $line = <$FH>) { $Path = $line; } my $dsn = "DBI:SQLite:" . $Path; print "Connecting $dsn ... \n"; my %attr = (RaiseError => 1, sqlite_unicode => 1, AutoCommit = +> 1); my $dbh = DBI->connect($dsn, "", "", \%attr) || die $DBI::errs +tr; print "done!\n";

What is wrong in the second script that pp doesn't like?


In reply to pp concatenate path by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.