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

I'm assigning some vars from values in @_ in a sub and getting some strange errors. real code is:

package QuestQRM; use strict; use Exporter; use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); @ISA = qw(Exporter); @EXPORT_OK = qw(repScreenOne); %EXPORT_TAGS = ( ':repReq'=>[qw!repScreenOne!] ) sub repScreenOne { my ($m,$d,$y) = @_; .... } 1;
I prepared a test case to post:
use strict; my $this = "1"; my $that = "2"; sub try { my ($one,$two) = @_; print "$one $two\n\n"; } try($this,$that);
but that works fine. when i run the first i get:
Can't use global @_ in "my" at QuestQRM.pm line 12. BEGIN failed--compilation aborted at /home/httpd/cgi-bin/rep_req.pl li +ne 24.
I'm stumped...jptxs is thuming through his books as you read this : )

-- I'm a solipsist, and so is everyone else. (think about it)

Replies are listed 'Best First'.
Re: illegal here not there?
by cianoz (Friar) on Oct 10, 2000 at 19:39 UTC
    try to add a semicolon (;) at the end of
    %EXPORT_TAGS = ( ':repReq'=>[qw!repScreenOne!] )
    :-)

      Bigger Update: It did fix that problem, i got mixed up copying files around...didn't copy new version. I'm having a bad day : )

      Update: Though still embarrasing, it doesn't seem to have been the problem, put in the semicolon - same error. still trying to post full code but getting 500s from the monastery - which makes me feel a lot better actually : )

      how embarrasing *blush*

      -- I'm a solipsist, and so is everyone else. (think about it)

Re: illegal here not there?
by merlyn (Sage) on Oct 10, 2000 at 19:36 UTC
Re: illegal here not there? - FULL CODE
by jptxs (Curate) on Oct 10, 2000 at 19:53 UTC

    full code. the only thing diff from the piece above is a whompin' big print statement:

    package QuestQRM; use strict; use Exporter; use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); @ISA = qw(Exporter); @EXPORT_OK = qw(repScreenOne); %EXPORT_TAGS = ( ':repReq'=>[qw!repScreenOne!] ); sub repScreenOne { my ($m,$d,$y) = @_; print qq! <HTML> <HEAD> <TITLE>QRM - Rep Requests</TITLE> <SCRIPT> function setStartDay(Day,Month,Year) { document.day_time.sday.selectedIndex = Day; document.day_time.smonth.selectedIndex = Month +; document.day_time.syear.selectedIndex = Year; } function DayMakeSense(){ document.day_time.eday.value = document.day_time.s +day.value; } function MonthMakeSense() { document.day_time.emonth.value = document.day_time +.smonth.value; } function YearMakeSense() { document.day_time.eyear.value = document.day_time. +syear.value; } function HourMakeSense() { document.day_time.ehour.selectedIndex = (document. +day_time.shour.selectedIndex + 1); } function MinuteMakeSense() { document.day_time.eminute.value = document.day_tim +e.sminute.value; } function AMPMMakeSense() { if (document.day_time.sampm[0].checked) {document. +day_time.eampm[0].click();} if (document.day_time.sampm[1].checked) {document. +day_time.eampm[1].click();} } function setScreen() { var value = "document.day_time.appt_typ +e.value"; var exp = /^\w+_(\w+)$/; var result = value.match(exp); if (result \!= null) { document.day_time.screen.value = result[1]; } } </SCRIPT> </HEAD> <BODY onLoad="setStartDay($d,$m,$y);DayMakeSense();MonthMa +keSense();YearMakeSense();setScreen();"> <FORM NAME="rep_req" +ACTION="http://scheduler.quest.com/cgi-bin/rep_req.pl" METHOD=POST> <FORM NAME="day_time" METHOD=POST ACTION="http://scheduler +/cgi-bin/rep_req.pl"> <TABLE> <TR><TD BGCOLOR="#A9A9A9"><B>Name of Quest Sales Rep:</B>< +/TD></TR> <TR><TD>First: <INPUT TYPE="text" NAME="rep_fname" SIZE=25 +></TD><TD>Last: <INPUT TYPE="text" NAME="rep_lname" SIZE=25></TD></TR +> <TR><TD BGCOLOR="#A9A9A9"><HR ALIGN="center" WIDTH="100%"> +</TD></TR> <TR><TD BGCOLOR="#A9A9A9"><FONT SIZE="2"><B>When to schedu +le:</B></FONT><HR ALIGN="center" WIDTH="100%"></TD></TR> <TR><TD BGCOLOR="#A9A9A9"><B>From:</B></TD></TR> <TR><TD> Day:&nbsp;&nbsp; <SELECT NAME="sday" SIZE="1" onChange="DayMakeSense();"> <OPTION SELECTED VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 <OPTION VALUE = "13">13 <OPTION VALUE = "14">14 <OPTION VALUE = "15">15 <OPTION VALUE = "16">16 <OPTION VALUE = "17">17 <OPTION VALUE = "18">18 <OPTION VALUE = "19">19 <OPTION VALUE = "20">20 <OPTION VALUE = "21">21 <OPTION VALUE = "22">22 <OPTION VALUE = "23">23 <OPTION VALUE = "24">24 <OPTION VALUE = "25">25 <OPTION VALUE = "26">26 <OPTION VALUE = "27">27 <OPTION VALUE = "28">28 <OPTION VALUE = "29">29 <OPTION VALUE = "30">30 <OPTION VALUE = "31">31 </SELECT>&nbsp;&nbsp; Month:&nbsp;&nbsp; <SELECT NAME="smonth" SIZE="1" onChange="MonthMakeSense(); +"> <OPTION SELECTED VALUE = "01">Jan <OPTION VALUE = "02">Feb <OPTION VALUE = "03">Mar <OPTION VALUE = "04">Apr <OPTION VALUE = "05">May <OPTION VALUE = "06">Jun <OPTION VALUE = "07">Jul <OPTION VALUE = "08">Aug <OPTION VALUE = "09">Sep <OPTION VALUE = "10">Oct <OPTION VALUE = "11">Nov <OPTION VALUE = "12">Dec </SELECT>&nbsp;&nbsp; Year:&nbsp;&nbsp; <SELECT NAME="syear" SIZE="1" onChange="YearMakeSense();"> <OPTION SELECTED VALUE = "00">00 <OPTION VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 </SELECT>&nbsp;&nbsp; Hour:&nbsp;&nbsp; <SELECT NAME="shour" SIZE="1" onChange="HourMakeSense();"> <OPTION SELECTED VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 </SELECT> :&nbsp;&nbsp; <SELECT NAME="sminute" SIZE="1" onChange="MinuteMakeSense( +);"> <OPTION SELECTED VALUE = "00">00 <OPTION VALUE = "15">15 <OPTION VALUE = "30">30 <OPTION VALUE = "45">45 </SELECT>&nbsp;&nbsp; <INPUT TYPE="radio" NAME="sampm" VALUE="AM" onClick="AMPMM +akeSense();">AM <INPUT TYPE="radio" NAME="sampm" VALUE="PM" onClick="AMPMM +akeSense();">PM </TD></TR> <TR><TD BGCOLOR="#A9A9A9"><B>To</B>:</TD></TR> <TR><TD> Day:&nbsp;&nbsp; <SELECT NAME="eday" SIZE="1"> <OPTION SELECTED VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 <OPTION VALUE = "13">13 <OPTION VALUE = "14">14 <OPTION VALUE = "15">15 <OPTION VALUE = "16">16 <OPTION VALUE = "17">17 <OPTION VALUE = "18">18 <OPTION VALUE = "19">19 <OPTION VALUE = "20">20 <OPTION VALUE = "21">21 <OPTION VALUE = "22">22 <OPTION VALUE = "23">23 <OPTION VALUE = "24">24 <OPTION VALUE = "25">25 <OPTION VALUE = "26">26 <OPTION VALUE = "27">27 <OPTION VALUE = "28">28 <OPTION VALUE = "29">29 <OPTION VALUE = "30">30 <OPTION VALUE = "31">31 </SELECT>&nbsp;&nbsp; Month:&nbsp;&nbsp; <SELECT NAME="emonth" SIZE="1"> <OPTION SELECTED VALUE = "01">Jan <OPTION VALUE = "02">Feb <OPTION VALUE = "03">Mar <OPTION VALUE = "04">Apr <OPTION VALUE = "05">May <OPTION VALUE = "06">Jun <OPTION VALUE = "07">Jul <OPTION VALUE = "08">Aug <OPTION VALUE = "09">Sep <OPTION VALUE = "10">Oct <OPTION VALUE = "11">Nov <OPTION VALUE = "12">Dec </SELECT>&nbsp;&nbsp; Year:&nbsp;&nbsp; <SELECT NAME="eyear" SIZE="1"> <OPTION SELECTED VALUE = "00">00 <OPTION VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 </SELECT>&nbsp;&nbsp; Hour:&nbsp;&nbsp; <SELECT NAME="ehour" SIZE="1"> <OPTION SELECTED VALUE = "01">01 <OPTION VALUE = "02">02 <OPTION VALUE = "03">03 <OPTION VALUE = "04">04 <OPTION VALUE = "05">05 <OPTION VALUE = "06">06 <OPTION VALUE = "07">07 <OPTION VALUE = "08">08 <OPTION VALUE = "09">09 <OPTION VALUE = "10">10 <OPTION VALUE = "11">11 <OPTION VALUE = "12">12 </SELECT> :&nbsp;&nbsp; <SELECT NAME="eminute" SIZE="1"> <OPTION SELECTED VALUE = "00">00 <OPTION VALUE = "15">15 <OPTION VALUE = "30">30 <OPTION VALUE = "45">45 </SELECT>&nbsp;&nbsp; <INPUT TYPE="radio" NAME="eampm" VALUE="AM">AM <INPUT TYPE="radio" NAME="eampm" VALUE="PM">PM </TD></TR> <TR><TD BGCOLOR="#A9A9A9"><HR ALIGN="center" WIDTH="100%"> +</TD></TR> <TR><TD BGCOLOR="#A9A9A9"><B>Contact name:</B></TD></TR> <TR><TD>Name: <INPUT TYPE="text" NAME="con_name" SIZE=60>< +/TD></TR> <TR><TD>Contact Phone: <INPUT TYPE="text" NAME="con_phone" + SIZE=25> Alternate Phone: <INPUT TYPE="text" NAME="con_phone" SIZE=2 +5></TD></TR> <TR><TD BGCOLOR="#A9A9A9"><HR ALIGN="center" WIDTH="100%"> +</TD></TR> <TR><TD COLSPAN=2 BGCOLOR="#A9A9A9"><B>What is the address + where the appointment will be?</B></TD></TR> <TR><TD>Street and Number:</TD> <TD><INPUT TYPE="text" NAM +E="street" SIZE=40></TD></TR> <TR><TD>City:</TD> <TD><INPUT TYPE="text" NAME="city" SIZE +=40></TD></TR> <TR><TD> <SELECT NAME="state"><OPTION VALUE="">State/Province<O +PTION VALUE=al>Alabama <OPTION VALUE=ak>Alaska <OPTION VALUE=az>Arizona <OPTION VALUE=ar>Arkansas <OPTION VALUE=ca>California <OPTION VALUE=co>Colorado <OPTION VALUE=ct>Connecticut <OPTION VALUE=de>Delaware <OPTION VALUE=dc>District Of Columbia <OPTION VALUE=fl>Florida <OPTION VALUE=ga>Georgia <OPTION VALUE=hi>Hawaii <OPTION VALUE=id>Idaho <OPTION VALUE=il>Illinois <OPTION VALUE=in>Indiana <OPTION VALUE=ia>Iowa <OPTION VALUE=ks>Kansas <OPTION VALUE=ky>Kentucky <OPTION VALUE=la>Louisiana <OPTION VALUE=me>Maine <OPTION VALUE=md>Maryland <OPTION VALUE=ma>Massachusetts <OPTION VALUE=mi>Michigan <OPTION VALUE=mn>Minnesota <OPTION VALUE=ms>Mississippi <OPTION VALUE=mo>Missouri <OPTION VALUE=mt>Montana <OPTION VALUE=ne>Nebraska <OPTION VALUE=nv>Nevada <OPTION VALUE=nh>New Hampshire <OPTION VALUE=nj>New Jersey <OPTION VALUE=nm>New Mexico <OPTION VALUE=ny>New York <OPTION VALUE=nc>North Carolina <OPTION VALUE=nd>North Dakota <OPTION VALUE=oh>Ohio <OPTION VALUE=ok>Oklahoma <OPTION VALUE=on>Ontario <OPTION VALUE=or>Oregon <OPTION VALUE=pa>Pennsylvania <OPTION VALUE=pr>Puerto Rico <OPTION VALUE=ri>Rhode Island <OPTION VALUE=sc>South Carolina <OPTION VALUE=sd>South Dakota <OPTION VALUE=tn>Tennessee <OPTION VALUE=tx>Texas <OPTION VALUE=ut>Utah <OPTION VALUE=vt>Vermont <OPTION VALUE=vi>Virgin Islands <OPTION VALUE=va>Virginia <OPTION VALUE=wa>Washington <OPTION VALUE=wv>West Virginia <OPTION VALUE=wi>Wisconsin <OPTION VALUE=wy>Wyoming </SELECT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </TD> <TD>Zip: <INPUT TYPE="text" NAME="zip" SIZE=9></TD> </TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Company's Primary + Business <BR> (IE: Manufacturing, Telecommunications, etc):</B> </TD></T +R> <TR><TD COLSPAN="2"> <INPUT TYPE="text" NAME="business" SI +ZE=integer></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Hardware Environm +ent with Quantity, Type, and Operating System<BR> (IE: 4 E3500 with Solaris 2.6 and/or 8 Quad PIII with Win +NT 4.0, etc):</B></TD></TR> <TR><TD COLSPAN="2"> <TEXTAREA NAME="hardware" ROWS="12" C +OLS="65"> </TEXTAREA></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Application(s) to + be Managed<BR> (IE: PeopleSoft, Oracle Apps, SAP, Apache server, etc):</B +></TD></TR> <TR><TD COLSPAN="2"><INPUT TYPE="text" NAME="apps" SIZE=65 +></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Databases involve +d:</B></TD></TR> <TR><TD COLSPAN="2"><INPUT TYPE="text" NAME="databases" SI +ZE=65></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Competition Being + Considered and Status:</B></TD></TR> <TR><TD COLSPAN="2"><TEXTAREA NAME="competition" ROWS="12" + COLS="65"> </TEXTAREA></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Customer Critical + Issues:</B></TD></TR> <TR><TD COLSPAN="2"> <TEXTAREA NAME="issues" ROWS="12" COL +S="65"> </TEXTAREA></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Issues to Avoid:< +/B></TD></TR> <TR><TD COLSPAN="2"> <TEXTAREA NAME="avoid" ROWS="12" COLS +="65"> </TEXTAREA></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><B>Travel Info Recom +mendations<BR> (Airport, Hotel, Rental Car Required, Departure Time, etc) +:</B> </TD></TR> <TR><TD COLSPAN="2"><TEXTAREA NAME="travel" ROWS="12" COLS +="65"> </TEXTAREA></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> <TR><TD COLSPAN="2" ALIGN="right"><INPUT TYPE="submit" VAL +UE="NEXT >>"></TD></TR> <TR><TD COLSPAN="2" BGCOLOR="#A9A9A9"><HR ALIGN="center" W +IDTH="100%"></TD></TR> </TABLE> </FORM> </BODY> </HTML> !; } 1;

    -- I'm a solipsist, and so is everyone else. (think about it)

      Im not sure merlyn was really asking for all the HTML, more the code verbatim from your script, cut and pasted.

      Though perhaps reading that 'whumping'(good word) great section of HTML from a file would make your code maintenance and debugging a whole lot easier????

        well, that is all the code : ) I'm putting the HTML stuff in a module so it's out of the way for now. I'm not planning on putting in a file and using SSI or something because of some constraints I'm under on how and where I can put files on this server - but I do agree it would be easier...

        -- I'm a solipsist, and so is everyone else. (think about it)

RE: illegal here not there?
by runrig (Abbot) on Oct 11, 2000 at 01:24 UTC
    With perl 5.6, I get an Exporter error until I change the EXPORT_TAGS line to this:
    %EXPORT_TAGS = (repReq=>[qw!repScreenOne!]);
    Also, I get warnings unless you double up the backslashes in the big quoted print statement. After that it seems to work.

    Update: Seems to work on 5.005_03 also.