Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^13: Flummoxed by strict.pm

by ikegami (Patriarch)
on May 10, 2010 at 03:02 UTC ( [id://839158]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^14: Got by Strict.pm!!!!
by CaptainRob (Novice) on May 10, 2010 at 19:11 UTC

    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.

        Corion, Thanks for the note. I put in the following lines;

        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 = 1; #New from Corion 11 my $backupoutput = 2; # you will get the warning here 12 print $backupoutput; # New from Corion 13 my $backupoutput = $filename; 14 print $backupoutput; 15 my $backupoutput =~ s{\.html*}{.entbackup.html}i; 17 open (IN, $filename); 18 my $book = join('',<IN>); 19 close IN; 21 open (OUT, ">$backupoutput"); 22 print OUT $book; 23 close OUT; 26 $book =~ s/‘/&lsquo;/g; 27 $book =~ s/’/&rsquo;/g;

        Many more lines of character change

        83 $book =~ s/û/&ucirc;/g; 84 $book =~ s/ü/&uuml;/g; 86 my $utf8 = qq!<meta http-equiv="Content-Type" content="text/html; c +harset=UTF-8" />!; 88 $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; 91 open (OUT, ">$filename") or die "Couldn't create '$filename': $!"; + #New from Corion 92 print OUT $book; 93 close OUT;

        And so I got:

        C:\Perl64\bin>perl entities_99.pl "my" variable $backupoutput masks earlier declaration in same scope at + entities_99.pl line 11. "my" variable $backupoutput masks earlier declaration in same scope at + entities_99.pl line 13. "my" variable $backupoutput masks earlier declaration in same scope at + entities_99.pl line 15. 2RAH99.htmlUse of uninitialized value $backupoutput in substitution (s +///) at entities_99.pl line 15. Use of uninitialized value $backupoutput in concatenation (.) or strin +g at entities_99.pl line 21. print() on closed filehandle OUT at entities_99.pl line 22.

        Does this suggest a new approach?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://839158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found