Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Undefined Subroutine

by KingNerd (Initiate)
on May 20, 2003 at 21:43 UTC ( #259592=perlquestion: print w/replies, xml ) Need Help??

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

I am writing a script which prints a bunch of HTML on the fly. Part of what I am printing out to the browser is a drop down box.


print"<SELECT NAME=reason>"; print"<OPTION SELECTED>- - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - -"; print"<OPTION>Deposits"; print"<OPTION>PPV Dispute"; print"<OPTION>Misquoted by sales"; print"<OPTION>Rate Increase"; print"<OPTION> Collections -- Write Off"; print"<OPTION> Misapplied Payment\n"; print"<OPTION> CSAP"; print"<OPTION> Trip Charge"; print"<OPTION> Refund Checks"; print"<OPTION> Customer Complaint"; print"<OPTION> Technical Issues-Installs\/Upgrades"; print"<OPTION> Non-Pay Issue"; print"<OPTION> EZ-Pay Issue"; print"<OPTION> Collections - NPD\n"; print"<OPTION> Telephone Slamming Investigation"; print"<OPTION> Technical Issues"; print"<OPTION> Campaign Not Applied"; print"<OPTION> Equipment Charges\n"; print"<OPTION> Customer Not Understanding Billing"; print"<OPTION> Not Receiving Bill In The Mail"; print"<OPTION> Wrong Mailing Address"; print"<OPTION> Wanting Payment Arrangements"; print"<OPTION> Disputing Non Pay Fee"; print"<OPTION> 3.99 Processing Fee (New England)"; print"<OPTION> 3.00 Processing Fee\n"; print"<OPTION> MLB Package Autorenewal Dispute\n"; print"<OPTION> Account Verification"; print"<OPTION> Bundling Discount\n"; print"</select>\n"; .......
If I add one more option (no matter what it is) like:
print"<OPTION> Compliment";
I get this error message:
Undefined Subroutine &main::stop called at line132.
If I remove the added <OPTION> Compliment, it goes back to working.

I understand that the error is probably not in this section of code, but can someone tell me what I should be looking for?

Its driving me crazy!

update (broquaint): added formatting + <code> tags

Replies are listed 'Best First'.
Re: Undefined Subroutine
by Limbic~Region (Chancellor) on May 20, 2003 at 22:05 UTC
    Web and database coding is almost non-existent for me, but I have seen the nodes concerning the pitfalls of not using modules for this sort of thing, so before I address your problem - may I suggest you check out CGI and HTML::Template.

  • You haven't provided the whole script and most likely line 132.
  • Are you running with warnings turned on?
  • Are you running under strict?

    You could help us help you by providing more of the code - considering what you did provide didn't contain the word stop in it anywhere.

    Cheers - L~R

Re: Undefined Subroutine
by Mr. Muskrat (Canon) on May 20, 2003 at 22:01 UTC
    Since you didn't post any code only the HTML in a form it's really difficult to help but I'll try anyway. Start by opening in your editor and go to line 132. Look for the word 'stop'. Perhaps the author meant to use 'exit' there instead.

    It sounds to me like the options that the script expects are hard coded.

Re: Undefined Subroutine
by arturo (Vicar) on May 21, 2003 at 01:57 UTC

    What the other fine monks hath said, plus the following: if you've got a simple list of variable size, you should be thinking "array." It's much less error-prone to let the program do your repetition for you, instead of manually typing in every line. For all we know, you left off a ; or a quote in one of those lines, or the line you've added (re-emphasize the 'for all we know' part =) and that's the source of your trouble. Compare:

    # OK, I'm a bit of a Standards freak, but you get my point =) print "<select name='reason'>\n"; foreach my $option (@options) { # make sure line containing only dashes is selected if ( $option =~ /^-+$/ ) { print "<option selected='selected'>"; } else { print "<option>"; } print "$option</option>\n"; }

    Now of course that forces you to set up the array beforehand, but that's not very difficult either:

    my @options = (); while (<DATA>) { chomp; push @options, $_; } # rest of program here, at the very end __DATA__ ----------------------------------------- Deposits PPV Dispute ...

    Anyhow, just a kind of general programming note for the future, a good way of reducing bugs is to let the computer repeat stuff for you instead of doing it yourself.


    If not P, what? Q maybe?
    "Sidney Morgenbesser"

Re: Undefined Subroutine
by little (Curate) on May 21, 2003 at 21:26 UTC

    Please rethink your use of quotes. As far as I can see you are forcing Perl to look through each string for possible variable interpolation.

    I really gonna wonder if

    print '<option> Compliment </option>'; # why omit the closing tag? # use this for pretty output print '<option> Compliment </option>' . "\n"; # or even like this use constant CRLF = "\n"; # ... print '<option> Compliment </option>' . CRLF ; # or use CGI::Pretty
    would lead to strange results as well as your
    print "<option> Compliment";
    At least the first one should run faster :-) Do you have any subs declared matching the one or the other "name" in your output strings? Do you, worst I could think of, have a filehandle called OPTION?

    Have a nice day
    All decision is left to your taste

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://259592]
Approved by broquaint
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2023-05-28 16:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found