adhocusage has asked for the wisdom of the Perl Monks concerning the following question:

I am following the book "Real World SQL Server Administration with Perl" by Linchi Shea. He has used 5.6.1 from ActiveState.com; Current / latest version available is ActivePerl-5.12.2.1202-MSWin32-x64-293621.msi for 64 bit and i installed it. perl -v showed the verion correctly. Many of the simple scripts run but when i try to run one of the scripts it is giving error regarding ParserSQL.pm; I invoked ppm and installed all the packages and a search after installing does not show any P*SQL.pm;

The error i am getting is:

Can't locate SQLDBA/PerseSQL.pm in @INC (@INC contains C:/Perl64/site/lib C:/Perl64/site/lib C:/Perl64/lib .) at .\reviewSP.pl line 5. BEGIN failed--compilation aborted at .\reviewSP.pl line 5.

The first few lines of reviewSP.pl are as follows:

# See the embedded POD or the HTML documentation use strict; use Data::Dumper; use SQLDBA::ParseSQL qw( dbaNormalizeSQL dbaSplitBatch ); Main: { my $dir = shift or die "***Err: $0 expects a directory name."; (-d $dir) or die "***Err: directory $dir does not exist.\n"; # read the file names in the directory opendir(DIR, $dir) or die "could not open $dir.\n"; my @fileNames = map { "$dir\\$_" } grep {!/^\.\.?/} readdir(DIR); closedir(DIR); my $counterRef;
I am newbie to PERL and any help would be appreciated. Thanks in Advance.

Replies are listed 'Best First'.
Re: SQL Server parser
by cdarke (Prior) on Nov 25, 2010 at 08:27 UTC
    SQLDBA::ParseSQL is not on the Comprehensive Perl Archive Network, and it is not part of the core. It appears that it is part of a SQLDBA toolkit produced for some specific books. I suggest you Google for it, or buy a different book.

    By the way, it would be nice and helpful for everyone for any future posts if you tried to be accurate with error messages and names. For example, you variously describe the module as SQLDBA/PerseSQL.pm in the error message (that could have meant a typo in your script), SQLDBA::ParseSQL in the code, and ParserSQL.pm in your question. It might seem picky to point this out, but that could lead us to do a lot more work than necessary in trying to help.

      Thanks for pointing the typo out. You are not mistaken for the same. Since it is windows i was not sure if the posting will allow me to cut paste the screen shot. May be errorlog could have been produced and cut pasted. Will do so next time.

Re: SQL Server parser
by ahmad (Hermit) on Nov 25, 2010 at 02:10 UTC

    A module that is required by your script is not installed on your system.

    Try installing it using ppm like this: ppm install SQLDBA-ParseSQL If it doesn't work ... you'll have to download it & build/install it yourself.

      ppm install SQLDBA-ParseSQL did not work. My bad luck. I will try installing Strawberry perl and see if it will have it. Thanks for the command.

        Strawberryperl won't have it either since it is not distributed on CPAN
      The book says => To verify the installation is correct, do the following :
      
      cmd> perl -e "use File::Copy;"
      
      cmd> perl -e "use Data::Dumper;"
      
      cmd> perl -e "use Win32::ODBC;"
      
      cmd> perl -e "use Getopt::Std;"
      
      
      
      All these commands return blank line which means the 
      installation is correct. They look for Copy.pm in File 
      subdirectory , Dumper.pm in Data subdirectory etc and the 
      directory and the perl module (pm) files are indeed 
      present. 
      
      However looking for SQLDBA::ParseSQL gives the following error
      
      cmd> perl -e "use SQLDBA::ParseSQL;"
      Can't locate SQLDBA/ParsSQL.pm in @INC 
      (@INC containts: C:/Perl/site/lib C:/Perl64/lib .) at -e line 1.
      BEGIN failed--compilation aborted at -e line 1.
      
      
      
      But i am not seeing SQLDBA subdirectory under either 
      C:\PERL64\lib or C:\PERL64\site\lib; So i created SQLDBA
       subdirectory under both the above directories and tried 
      
      cmd> ppm install SQLDBA-ParseSQL
      
      It ends up giving me the following message:
      
      Downloading ActiveState Package Repository packlist...done
      Updating ActiveState Package Repository database...done
      Syncing site PPM database with .packlists...done
      ppm instail failed: Can't find any package that provides 
      SQLDBA-ParseSQL.
      
      Also , i would like to know where to find and edit the 
      @INC entry. I am working in Windoz and the path should 
      have backslash (\) and not forward slash (/). 
      
      Any suggestions would be welcome. 
      
      
      
        Ok. The author mentions the following are the functions exported by the SQLDBA::Utility
        
        dbaReadINI()
        dbaReadConfig()
        dbaInSet()
        dbaSetCommon()
        dbaSetDiff()
        dbaSetSame()
        dbaRemoveDuplicates()
        dbaTime2str()
        dbaStr2time()
        dbaTimeDiff()
        dbaStringDiff()
        dbaSaveRef()
        dbaReadSaveRef()
        dbaRunQueryADO()
        dbaRunOsql()
        dbaGetTree()
        
        I am seeing the code for the functions. How do i arrive at 
        the .pm file? Do i just concatenate them together or is 
        there any import module? If so how do i do that?
        
        
        Thanks