in reply to Re: Perl ODBC Drivers
in thread Perl ODBC Drivers

Slightly better, assuming you have perl 5.10.0 or later:
perl -MDBD::ODBC -E 'say $DBD::ODBC::VERSION'
From perlrun
-E commandline

behaves just like -e, except that it implicitly enables all optional features (in the main compilation unit). See feature.
Saves you two characters and adds a newline to the output.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^3: Perl ODBC Drivers
by stevieb (Canon) on Oct 28, 2015 at 16:01 UTC

    Yes, I'm aware and most often use -E. It was just early, and just in case someone tested it that doesn't have a recent enough version for say(). :) Good to point out for those who don't know. In a one-liner, say() is especially useful when iterating.

      If print/say is the only issue, changing -E to -le will make print work the same as say. Furthermore, that will work in very old Perls (at least 5.6, but I expect much earlier).

      I often find I need to check the versions of multiple modules so I wrote this function for that:

      perlmodver () { for i in "$@"; do eval "echo \`perl -E 'no warnings q{deprecated}; use $i; say q +q{$i }, \$$i::VERSION'\`" done }

      Example usage:

      $ perlmodver DBD::ODBC DBD::SQLite DBI Can't locate DBD/ODBC.pm in @INC (you may need to install the DBD::ODB +C module) (@INC contains: /Users/ken/local/lib/perl /Users/ken/perl5/ +perlbrew/perls/perl-5.22.0t/lib/site_perl/5.22.0/darwin-thread-multi- +2level /Users/ken/perl5/perlbrew/perls/perl-5.22.0t/lib/site_perl/5.2 +2.0 /Users/ken/perl5/perlbrew/perls/perl-5.22.0t/lib/5.22.0/darwin-th +read-multi-2level /Users/ken/perl5/perlbrew/perls/perl-5.22.0t/lib/5. +22.0 .) at -e line 1. BEGIN failed--compilation aborted at -e line 1. DBD::SQLite 1.46 DBI 1.633

      — Ken