in reply to external subroutine

Everything you have said is correct, but for the phrase "using that code it should... call the WasonE subroutine". The code you have posted doesn't automatically call the WasonE subroutine, it is just imported into your namespace. You need to add a manual call to the subroutine:

#!/usr/bin/perl -wT use strict; use CGI qw(:standard); use lib "/home/public_html/cgi-bin"; use DATA99 qw(WasonE); WasonE();

As for the errors being genereated in your error log, it has nothing to do with the code segments you've posted here. The warnings would be coming from within the WasonE() subroutine and are being added to your error log because you've globally enabled warnings (via the '-w' switch on the shebang line). Try adding the WasonE(); line and if you've programmed things correctly/logically, it should work fine.

Replies are listed 'Best First'.
Re: Re: external subroutine
by Anonymous Monk on May 20, 2004 at 04:58 UTC
    It made a lot of sense, to call the subroutine, almost too much. But unfortunatly it still does not work.
    I now have this all over my error log:
    Use of uninitialized value in string ne at WasonE.cgi line 191. Use of uninitialized value in string ne at WasonE.cgi line 187.
    The ne that it is refering to is:
    if ($WasonE{HSname} ne "") { print "<th>" . $WasonE{HSname} . "</th>\n"; }
    The whole ne is to say if the value is not black print the value. I know it worked before because before I tried to make it an external file it worked fine.
    Further advice?

      Ah k, in cases where you want to print out a value only if it is 'blank', you want to test for a defined value rather than a blank one:

      print "<th>$WasonE{HSName}</th>\n" if ( defined( $WasonE{'HSName'} ) );

      This will get rid of the warnings you are seeing in your log file, though this will not fix any actual errors. When you run the script in the browser, does it still work as expected, even though you have a lot of warnings in the error log?

        That worked, as far as getting rid of the errors. However The variables ARE defined. Here is the code:

        DATA99.pm
        package DATA99; require Exporter; our @ISA = ("Exporter"); our @EXPORT_OK = qw(WasonE); sub WasonE { $WasonE{"time"} = ""; $WasonE{"HSname"} = "E Wason"; $WasonE{"cName"} = "E Wason"; $WasonE{"nickName"} = ""; $WasonE{"yearsHS"} = "4"; $WasonE{"gender"} = "Male"; $WasonE{"wiptabor"} = "I am an accomplished tattooer currently tattooi +ng out of Lucky Draw Tattoo in Glendale. I plan on furthering my care +er, getting some travelling in, and possibly getting a house with my +girlfriend."; $WasonE{"online"} = "I'm on quite a bit actually. I'm currently rebuil +ding the Lucky Draw website offline. Look for it in a few months. I'm + on AIM constantly, and frequent Livejournal. IM me anytime. "; $WasonE{"yahoo"} = ""; $WasonE{"aim"} = ""; $WasonE{"msn"} = ""; $WasonE{"Last4"} = "I've been tattooing since early 2000. I almost got + engaged to a prior girlfriend, but that fell through. I moved to Gle +ndale, to Tempe, and then back to Glendale when I was offered a posit +ion at Lucky Draw. I met a nice English girl named Lee-Ann and we've +been dating for just over a year now."; $WasonE{"Relationship"} = "Yes"; $WasonE{"family"} = "I hang out with my family quite a bit."; $WasonE{"kids"} = "Not Yet"; $WasonE{"hobbies"} = "tattooing, drawing, watching movies..."; $WasonE{"School"} = ""; $WasonE{"Major"} = ""; $WasonE{"Graduation"} = ""; $WasonE{"SchoolLife"} = ""; $WasonE{"jobs"} = "see above"; $WasonE{"military"} = ""; $WasonE{"Memories"} = "lunches on the steps behind the 400 building wi +th Brandon and everybody. Classes with Mr Nielsen."; $WasonE{"fTeacher"} = "Mr Nielsen"; $WasonE{"Clubs"} = ""; $WasonE{"bFriend"} = ""; $WasonE{"friends"} = ""; $WasonE{"Dated"} = "nobody of significance"; @WasonE = values(%WasonE); } 1;
        WasonE.cgi
        #!/usr/bin/perl -wT use strict; use CGI qw(:standard); use lib "/home/bgregory/public_html/cgi-bin"; use DATA99 qw(WasonE); my $q = new CGI; my %WasonE; my $key; my $WasonE; my $name; my $value; my @WasonE; WasonE(); print $q->header( "text/html" ); print "<html>\n<head>\n"; print <<END_OF_HEADER; </head> <body> <table id="top"> <thead> <tr> END_OF_HEADER print <<END_OF_th; </tr> </thead> <tbody> <tr> <td> <h4 id=\"info\">Quick Info:</h4> END_OF_th print "<th>$WasonE{HSName}</th>\n" if ( defined( $WasonE{'HSname'} ) ); print <<END_OF_page; </td> </tr> </tbody> </table> </body> </html> END_OF_page exit;
        thx
      I think you'll need to show a little more code for this to make sense. The fact that the perl interpreter seems to think that "ne" is a string that is supposed to be initialized with a value leads me to think that you have a mis-matched bracket somewhere, or some similar sort of typo that is throwing off the syntax in your cgi script. Or maybe it's a mis-matched quote operator somewhere, or a misplaced "#".

      If the editor you use for writing perl scripts supports jumping to a matching bracket, use that facility on the open and close parens, open and close curlies, and any nearby square brackets on and near the line that triggered the error. Syntax highlighting, which renders quoted strings and comments in a different colors than the rest of the code, can also be a big help.

      Nevermind -- sorry to have misread the warning message.