perl - 'Unquoted string ".." may clash with future reserved word' but only when package is used -
I ran into this problem while trying to reactor one of my modules in the object-oriented code. I compressed it down to the bottom. Here is the list of 3 files I am using:
_mypkg.pm:
Usage _debug; Use _debug dprint; Package mypkg; Sub New {my ($ class,% args) = @_; My $ self = blessing {}, $ square; DPPrint "PKG
\ n"; Return $ self; } 1;
_debug.pm:
# package mydebug; # Getting this line gets an error 500 $ my bprint = ""; Sub print_now {print "print:". $ Bprint; $ Bprint = "";} Subprint {$ bprint. = "@_"; } Subdeprint {bprint @_; } 1;
testfile.cgi:
#! / Usr / bin / perl is required '_mypkg.pm'; #require '_debug.pm'; #use_debug; Use _debug dprint; Print "content-type: text / html \ n \ n"; DePrint "First & lt; br & gt; \ n"; & Amp; Print_now; My $ somepkg = mypkg- & gt; new (); DePrint "Second & lt; br & gt; \ n"; & Amp; Print_now;
As they appear above, there is no output, but commenting on lines:
is required '_mypkg.pm'; My $ somepkg = mypkg- & gt; new (); In testfile.cgi, the following (expected) output goes to: printing: first printing: second
P> Runs the script (without modification) - leads to the following output in the error log (a bit trim for clarity):
unquoted string "dprint" reserved for future Conflicts with the word can be unquote, "mimeji" can fight with future reserved word strings, where oper The doctor _mypkg.pm, "Deepiaianti" Pikeji & lt; Br> \\ n "" \ t (_M) Need to predict the syntax error on _mypkg?
Basically, I want to use DPINT (defined in Dedebug.M.M.), to replace "dprint" pkg and lt; Br> \\ n "In my scripts" print "(i.e., without brackets or A and) and it has worked perfectly until I try to use it in the module where I try to use objects That is, "package", so how can I fix it?
Your code There are a lot of problems, some of which I'm not sure are typo or not, for example, your files In _mypkg.pm
you have a cleaned version of package >> instead of
package_mypkg;
.
- Take a careful look at the differences, if you need, consult. You should also come in the habit of using hard;
and use warnings;
your script At the top, and in the CG environment, use CGI: carp ('weightless tubrose');
invaluable while testing Use can be programmed to
_mypkg.pm
Package _mypkg; _debug qw (dprint); # Import dprint () Sub New {my ($ class,% args) = @_; My $ self = blessing {}, $ square; DPPrint "PKG
\ n"; Return $ self; } 1;
_debug.pm
package _debug; Exporters use 'import'; Our @EXPORT_OK = qw (print_now dprint); My $ bprint = ""; Sub print_now {print "print:". $ Bprint; $ Bprint = "";} Subprint {$ bprint. = "@_"; } Subdeprint {bprint @_; } 1;
testfile.cgi
#! Use / usr / bin / perl strict; Use warnings; _mypkg; Use _debug qw (print_now dprint); # Import print_now () and dprint () print "content-type: text / html \ n \ n"; DePrint "First & lt; br & gt; \ n"; Print_now; My $ somepkg = _mypkg- & gt; new (); Print_now; DePrint "Second & lt; br & gt; \ n"; Print_now;
Comments
Post a Comment