in reply to Re^11: Flummoxed by strict.pm
in thread Flummoxed by strict.pm

Thanks again for pursuing this thread, ikegami

So that I would be sure that I had perl working, I did a hello world as follows:

#!/usr/bin/perl -w print "Hello, world!\n";

For which I got this:

C:\Perl64\bin>Hello_world_test.pl Hello, world!

Naturally, I added a 'use strict;' line as follows to the script:

#!/usr/bin/perl -w use strict; print "Hello, world!\n";

For which I got:

C:\Perl64\bin>Hello_world_test.pl Can't locate strict.pm in @INC (@INC contains: .) at C:\Perl64\bin\Hel +lo_world_t est.pl line 2. BEGIN failed--compilation aborted at C:\Perl64\bin\Hello_world_test.pl + line 2.

I can find strict.pm in lib, but apparently Perl can't

Does this suggest an approach? If you are bored with this thread, I shall certainly understand.

Replies are listed 'Best First'.
Re^13: Flummoxed by strict.pm
by BrowserUk (Patriarch) on May 10, 2010 at 00:40 UTC

    What output do you get if you add this to the end of your Hello_world_test.pl script?

    #!/usr/bin/perl -w print "Hello, world!\n"; print "$^X\n";

    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 note. we may be getting somewhere, because the path shows a path to a Perl that i have in XAMPP, not in C:/perl64/bin. Ikegami said that I might have two Perls installed, and so I do. This is what I got:

      C:\Perl64\bin>Hello_world_test.pl Hello, world! C:\xampp\perl\bin\perl.exe

      The Xampp Perl does not have the lib with the strict.pm; the Perl64 lib does. Seeing this, I tried to change the path in the Perl file to:

      #!c:/perl64/bin/perl.exe print "Hello, world!\n"; print "$^X\n";

      with the result:

      'Hello_world_test_1.pl' is not recognized as an internal or external c +ommand operable program or batch file.

      so, how do I make it go to the C:/perl64/bin/?

      Thanks for any help

        The Xampp Perl does not have the lib with the strict.pm;

        Then it is broken by design and should be scrapped.

        Seeing this, I tried to change the path in the Perl file to: #!c:/perl64/bin/perl.exe

        As I told you back up there somewhere, Windows doesn't use the shebang line. (Though Apache under Windows might). That's why I though you might also have Cygwin installed.

        If you use a Cygwin shell, that will emulate the *nix-style of shebang processing. Maybe the XAMPP Shell is something similar?

        What output do you get from: set

        What output do you see from: ftype | find "perl"?

        so, how do I make it go to the C:/perl64/bin/?

        Switch to an account with sufficient privileges and fix the association as you tried earlier.

Re^13: Flummoxed by strict.pm
by ikegami (Patriarch) on May 10, 2010 at 03:02 UTC
    I don't know how Windows knows to execute Perl for .pl for you*, and I don't know which Perl it finds, but I suspect that the following will work without error:
    C:\Perl64\bin>perl Hello_world_test.pl

    If so, you might find $^X to differ depending on whether you launch the script via the extension (no leading "perl") or via the path (with leading "perl").

    * — I suspect the association is there, but the same permission issue that's preventing you changing it is also silently preventing you from seeing it.

      Thanks,Ikegami, for the steer

      First, I went into the Windows control panel and associated all .pl files with the perl.exe located in C:/perl64/bin and then, I put the 'perl' in the command line just so:

       C:\Perl64\bin>perl Hello_world_test.pl

      Just as you said.

      Then I got:

      C:\Perl64\bin>Perl entities_99.pl "my" variable $backupoutput masks earlier declaration in same scope at + entities_99.pl line 11. Use of uninitialized value $backupoutput in substitution (s///) at ent +ities_99.pl line 11. Use of uninitialized value $backupoutput in concatenation (.) or strin +g at entities_99.pl line 17. print() on closed filehandle OUT at entities_99.pl line 18.

      Of course, I don't understand what that means...yet. The script that perl is trying to execute is, as I said several posts ago, is one which operates on an HTML file to change all the entities to HTML, " to “ and so on. Here is the famous strict.pm requiring script:

      1 #!/usr/bin/perl -w 4 use strict; 5 use Data::Dumper; 6 $|=1; #makes the macro produce all results at once, not in spurts 8 my $filename = "RAH99.html"; 9 my $output = $filename; 10 my $backupoutput = $filename; 11 my $backupoutput =~ s{\.html*}{.entbackup.html}i; 13 open (IN, $filename); 14 my $book = join('',<IN>); 15 close IN; 17 open (OUT, ">$backupoutput"); 18 print OUT $book; 19 close OUT; 22 $book =~ s/‘/&lsquo;/g; 23 $book =~ s/’/&rsquo;/g;

      Lots more exchange lines

      79 $book =~ s/û/&ucirc;/g; 80 $book =~ s/ü/&uuml;/g; 82 my $utf8 = qq!<meta http-equiv="Content-Type" content="text/html; c +harset=UTF-8" />!; 84 $book = "I have changed the most common Unicode characters into HTM +L entities.\n\nUse this search term to find any leftovers: [€-ÿ]\n\nA +lso, don't forget to add a UTF-8 meta tag to your header:\n\n$utf8\n\ +n".$book; 87 open (OUT, ">$filename"); 88 print OUT $book; 89 close OUT;

      If these error messages suggest a place for me to start looking, I would appreciate it

      Once again, many thanks to ikegami, BrowserUK and all that have taken the time to share their thoughts on the missing strict.pm

        87 open (OUT, ">$filename");

        You are not checking for error there. This line should be:

        87 open (OUT, ">$filename") or die "Couldn't create '$filename': $!";

        For the warning about $backupoutput, that means you have somewhere something like:

        my $backupoutput = 1; ... my $backupoutput = 2; # you will get the warning here print $backupoutput;

        Usually this happens when you get trigger-happy and add my before everything that looks like a variable, and then add one my too many.