Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Error with require LABEL;

by tangent (Parson)
on Dec 20, 2013 at 00:11 UTC ( [id://1067900]=note: print w/replies, xml ) Need Help??


in reply to Error with require LABEL;

I don't have any experience writing command line scripts but I don't think you can switch between one script and the other like the way you are trying. If I were writing this I would use modules, something like this:

File unit6.pl

#!/usr/bin/perl use strict; use warnings; require Unit6; require CMQIA; # require Quadrilaterals; etc Unit6::run();

File Unit6.pm

package Unit6; use strict; use warnings; sub run { print " This is Unit 6 - Quadrilaterals and Polygons.\n For the Final Exam, you will have to know the\n properties of all quadrilaterals and how to\n prove that a given shape is any quadrilateral.\n To access the Quadrilateral Information Database,\n type 'Quads.' To access the Casio-Maxim Quadrilateral\n Identification Algorithm, type 'crazy Maxim.'\n Type 'quit' to exit Unit 6.\n Type your choice.\n\n"; my $Choice = <STDIN>; chomp $Choice; if ($Choice =~ /quit/i) { print "\nBye.\n\n"; exit;} elsif ($Choice =~ /quads/i) { Quadrilaterals::run();} elsif ($Choice =~ /crazy maxim/i) { CMQIA::run();} } 1;

File CMQIA.pm

package CMQIA; use strict; use warnings; sub run { print " Welcome to the Casio-Maxim Quadrilateral Identification\n Algorithm. In order to identify said quadrilateral,\n you must have the coordinates of all 4 vertices.\n"; print " When you are ready to input your coordines, type\n 'ready.' Type anything else to exit the CMQIA.\n\n"; my $Choice = <STDIN>; chomp $Choice; if ($Choice =~ /ready/i) { maxim();} else { Unit6::run();} } sub maxim { print "\nFor shape ABCD, in which point A has coordinates (X1, Y1) +, B has coordinates\n\n(X2, Y2), C has coordinates (X3, Y3), and D ha +s coordinates (X4, Y4),\n\nX1 = "; my $AX = <STDIN>; chomp $AX; print "Y1 = \n"; my $AY = <STDIN>; chomp $AY; print "X2 = \n"; # etc } 1;

Replies are listed 'Best First'.
Re^2: Error with require LABEL;
by slinky773 (Sexton) on Dec 20, 2013 at 01:39 UTC
    Ohhh, I see. yeah, I looked around and whenever someone asked about require LABEL; or do LABEL; they always said to just use modules. I didn't really get what they meant, but I do now. Thanks.

      Just curious: Is  require LABEL; valid statement syntax? I don't see any mention of it in 5.8, 5.14 or 5.18 require documentation. Where do you see this syntax?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1067900]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found