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

Monks! (& ladies, one hopes),

First, thanks for looking at this post. Newbie, and what's worse, a Windows guy until I grow up and get a real OS.

Nonetheless, I am being flummoxed running a perl script from the command line. The script is meant to process an HTML file and change out the unicode characters for HTML entities, e.g. " goes to &rdquo.

The command line & the error message is:

C:\Perl64>entities_99.pl

Can't locate strict.pm in @INC (@INC contains: .) at C:\Perl64\bin\entities_99.pl line 2.

BEGIN failed--compilation aborted at C:\Perl64\bin\entities_99.pl line 2

So, where do I direct my script to find strict.pm?

Here's the script:

#!/usr/bin/perl use strict; use Data::Dumper; $|=1; #makes the macro produce all results at once, not in spurts my $filename = "RAH99.html"; my $output = $filename; my $backupoutput = $filename; my $backupoutput =~ s{\.html*}{.entbackup.html}i; open (IN, $filename); my $book = join('',<IN>); close IN; open (OUT, ">$backupoutput"); print OUT $book; close OUT; $book =~ s/‘/&lsquo;/g;

Lots more entity substitution lines, omitted for brevity

$book =~ s/ü/&uuml;/g; my $utf8 = qq!<meta http-equiv="Content-Type" content="text/html; char +set=UTF-8" />!; $book = "I have changed the most common Unicode characters into HTML e +ntities.\n\nUse this search term to find any leftovers: [€-ÿ]\n\nAlso +, don't forget to add a UTF-8 meta tag to your header:\n\n$utf8\n\n". +$book; open (OUT, ">$filename"); print OUT $book; close OUT;

So, why wouldn't ActiveState have strict.pm, well, never mind that; how do I find strict.pm to make this script work?

Or any other comment that could make this work

Many thanks to any and all Monks who can take the time to assist a wandering Newbie

Captain Rob

Replies are listed 'Best First'.
Re: Flummoxed by strict.pm
by BrowserUk (Patriarch) on May 07, 2010 at 03:05 UTC
    So, why wouldn't ActiveState have strict.pm,

    AS perl *always* comes with strict.pm. If it isn't being found, it's because your installation is broken.

    What do you get if you run this command?

    perl -V:archlib -V:installsitelib

    And how did you do the installation of your AS perl?

    My guess is that you downloaded & unpacked the .ZIP, but didn't run the install script?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      BrowserUK,

      Thanks for the suggestion. This is what I got on the command line:

      C:\>perl -V:archlib -V:installsiteli archlib='C:\Perl64\lib'; installsitelib='C:\Perl64\site\lib';

      Still the same error message

      But thanks for the suggestion

        And if you do

        dir C:\Perl64\lib\s*.pm
Re: Flummoxed by strict.pm
by ikegami (Patriarch) on May 07, 2010 at 05:34 UTC

    (@INC contains: .)

    You have a broken install. If the Perl executable is located at

    C:\path\to\perl\bin\perl.exe
    then @INC should contain
    C:/path/to/perl/site/lib C:/path/to/perl/lib .

    Those directories are missing, and thus not added to @INC. A permission issue might do it too.

Re: Flummoxed by strict.pm
by sflitman (Hermit) on May 07, 2010 at 05:26 UTC
    Your life would be easier if you use the excellent CPAN module HTML::Entities, since it handles a lot of the entity substitution issues. The strict issue probably is a poor installation, you could reinstall ActivePerl or try Strawberry Perl on windoze ;-).

    HTH,
    SSF

Re: Flummoxed by strict.pm
by ikegami (Patriarch) on May 07, 2010 at 05:41 UTC

    You're creating a UTF-8 file, so why are you bothering to converting anything but "&" and "<" (and """ in attribute values) to entities?

    The header you're adding is also fishy. Specifying a Content-Type header in an XHTML document is useless (as the encoding comes from the <?xml?> directive), and the trailing "/" is invalid in HTML.

Re: Flummoxed by strict.pm
by rovf (Priest) on May 07, 2010 at 07:18 UTC
    • If you exchange the use strict; line and the use Data::Dumper; line, does Perl then complain that it does not find Data::Dumper?
    • Do you get the same error message if you do a perl -e "use strict;" from the command line?

    -- 
    Ronald Fischer <ynnor@mm.st>

      If you exchange the use strict; line and the use Data::Dumper; line, does Perl then complain that it does not find Data::Dumper? ( YES )

      Do you get the same error message if you do a perl -e "use strict;" from the command line? ( NO )

      Please help I cant get away with this stupid windows error. I have windows 7 AS Perl 5.14.2 installed from binary .msi and Now i am compiling source code of Perl-5.14.2 with nmake command. I have VS 2008 installed with VC++. Please help me any body. Its urgent.

      Commands that I tried:

      D:\Perl-5.14.2\win32>perl -V:archlib -V:installsitelib

      archlib='D:\Perl\lib'; installsitelib='D:\Perl\site\lib';

      D:\Perl-5.14.2\win32>perl -e "use strict;"

      ( NO ERRORS ON DOS PROMPT )

      D:\Perl-5.14.2\win32>dir D:\Perl\lib\s*.pm

      Volume in drive D has no label. Volume Serial Number is E48A-1C28 Directory of D:\Perl\lib 03/19/2011 05:41 AM 25,267 Safe.pm 03/19/2011 05:41 AM 2,612 SDBM_File.pm 02/09/2010 01:34 PM 1,130 SelectSaver.pm 03/19/2011 05:41 AM 17,814 SelfLoader.pm 03/19/2011 05:41 AM 8,991 Shell.pm 03/19/2011 05:41 AM 7,933 sigtrap.pm 03/19/2011 05:41 AM 22,132 Socket.pm 02/09/2010 01:34 PM 6,289 sort.pm 07/11/2011 08:56 PM 41,314 Storable.pm 02/09/2010 01:34 PM 3,863 strict.pm 01/13/2010 03:06 PM 882 subs.pm 02/09/2010 01:34 PM 4,964 Symbol.pm 12 File(s) 143,191 bytes 0 Dir(s) 4,878,151,680 bytes free

      D:\Perl-5.14.2\win32>Perl -V

      Summary of my perl5 (revision 5 version 14 subversion 2) configuration +: Platform: osname=MSWin32, osvers=5.2, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D +_CONSOLE - DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT +_CONTEXT - DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-MD -Zi -DNDEBUG -O1', cppflags='-DWIN32' ccversion='15.0.21022', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64 +', lseeksi ze=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -l +ibpath:"D: \Perl\lib\CORE" -machine:x86' libpth=\lib libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib +comdlg32.l ib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid. +lib ws2_32 .lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.l +ib msvcrt. lib perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.l +ib comdlg 32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib u +uid.lib ws 2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl +32.lib msv crt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl514.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt: +ref,icf - libpath:"D:\Perl\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB +_ALLOC USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PE +RL_ATOF USE_SITECUSTOMIZE Locally applied patches: ActivePerl Build 1402 [295342] Built under MSWin32 Compiled at Oct 7 2011 15:49:44 %ENV: PERL5LIB="D:/Perl/bin;D:/Perl/lib;D:/Perl/site/bin;D:/Perl/site/li +b/Perl" @INC: D:/Perl/bin D:/Perl/lib D:/Perl/site/bin D:/Perl/site/lib/Perl D:/Perl/site/lib D:/Perl/lib .

        The Command I am executing and the errors that I am getting.

        D:\Perl-5.14.2\win32>nmake

        Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. ..\miniperl.exe -I..\lib create_perllibst_h.pl Can't locate strict.pm in @INC (@INC contains: lib \cpan\AutoLoader\li +b \dist\Cw d \dist\Cwd\lib \dist\ExtUtils-Command\lib \dist\ExtUtils-Install\lib +\cpan\ExtU tils-MakeMaker\lib \dist\ExtUtils-Manifest\lib \cpan\File-Path\lib \ex +t\re \cpan \Text-ParseWords\lib \lib .) at create_perllibst_h.pl line 5. BEGIN failed--compilation aborted at create_perllibst_h.pl line 5. NMAKE : fatal error U1077: 'C:\Windows\system32\cmd.exe' : return code + '0x2' Stop.

        D:\Perl-5.14.2\win32>

Re: Flummoxed by strict.pm
by Khen1950fx (Canon) on May 07, 2010 at 02:32 UTC
    I found a post by Nicholas Clark. He suggests adding a BEGIN block just before use strict
    #!/usr/bin/perl BEGIN { unshift @INC, "lib" } use strict; use Data::Dumper; $| = 1; #makes the macro produce all results at once, not in spurts my $filename = "RAH99.html"; my $output = $filename; my $backupoutput = $filename; my $backupoutput =~ s{\.html*}{.entbackup.html}i; open( IN, $filename ); my $book = join( '', <IN> ); close IN; open( OUT, ">$backupoutput" ); print OUT $book; close OUT; $book =~ s/\u0091/&lsquo;/g;
Re: Flummoxed by strict.pm
by CaptainRob (Novice) on May 07, 2010 at 16:49 UTC

    Monks, one and all,

    Thanks for the warm welcome and taking your monk-time away from other pursuits to provide a little guidance for a wandering Newbie

    So, thanks to Khen1950fx, BrowserUK, sflitman, ikegami Jovf and others for contributing to the non-delinquency of new Perl guy

    Now to try some of these great suggestions