Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Undefined Subroutine

by arturo (Vicar)
on May 21, 2003 at 01:57 UTC ( #259625=note: print w/replies, xml ) Need Help??


in reply to Undefined Subroutine

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.

HTH

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://259625]
help
Chatterbox?
[choroba]: also, you get stronger by carrying the rune stones along
[erix]: haha
[karlgoethebier]: shmem: This repertoire is a real challenge.
Discipulus mwhwhaa..
[Discipulus]: sucked in traslation.. was'nt a movie?
[karlgoethebier]: adds "Der abenteuerliche Simplicissimus" by Hans Jakob Christoffel von Grimmelshausen
Corion joins another telephone call :-/
[Discipulus]: also The Life and Opinions of the Tomcat Murr

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2017-05-24 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?