If I try it without the single quotes within the func declaration, I get a strict subs error

Something like this?

#!/bin/env perl # create a SQLite test database use strict; use warnings; use DBI; my $db = shift @ARGV || 'no_name.splite'; my $dbh = DBI->connect( "dbi:SQLite:$db", "", "", { RaiseError => 1, sqlite_see_if_its_a_number => 1, PrintError => 0 } ); $dbh->func('sqrt_s_s', -1, \&sqrt_sum_of_sqrs, 'create_function'); # n +eed length function my @rowa = $dbh->selectrow_array( "select 3 as A, 4 as B, sqrt_s_s( 3, + 4 ) as C" ); print join( "\t", @rowa ), "\n"; sub sqrt_sum_of_sqrs { my $sum_sqrs = 0.0; map { $sum_sqrs += $_ ** 2 } @_; return sqrt( $sum_sqrs ); }

Update: So now you need to research three things.

  1. How would you prompt a user for input?
  2. How to get the user input?
  3. How do you pass the user input into your function?


In reply to Re^3: DBI::Shell sqlite dbh->func( by Mr. Muskrat
in thread DBI::Shell sqlite dbh->func( by rodinski

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.