CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
What is this called?

 



Iconx
Novice

Apr 9, 2015, 1:04 PM

Post #1 of 2 (5317 views)
What is this called? Can't Post

What is this GET_MOD_FUNC: and SWITCH:
Whats this construct called?


Code
sub Modify_Acct 
646 {
647 print "Modify::Modify_Acct() sub \n";
648
649 my $opt_range = 7;
650
651
652
653 GET_MOD_FUNC: <-------
654 {
655
656 print "\n MODIFY ACCOUNT MENU\n\n";
657 foreach my $option (sort keys %mod_menu)
658 {
659 print("\t$option) $mod_menu{$option}\n");
660 print("\n") if ($option =~ /\d/ and $option == $opt_range);
661 }
662 print "\n\tInput Option (1-$opt_range): ";
663 $tinput = Utility::get_single_char();
664 print "$tinput\n";
665 if ( ($tinput !~ /(R|H|X|r|h|x)/)
666 && (($tinput < 1) || ($tinput > $opt_range)))
667 {
668 print
669 "\n$SEP\n\n ERROR: That is not a valid option. Please try again.\n\n$SEP\n";
670 &Modify_Acct;
671 }
672 SWITCH: <-------
673 {
674 if ($tinput =~ /\d/) { last SWITCH }
675 if ($tinput =~ /(R|r)/) { Amt::Main_Menu(); last SWITCH }
676 if ($tinput =~ /(X|x)/) { Utility::Exit(0) }
677
678 Utility::eprint("Invalid input. Try again.");
679 redo GET_MOD_FUNC;
680 }
681 print "\n MODIFY ACCOUNT\n";
682 &Input_Account;
683 #
684 # Call appropriate routine for the selection modify function
685 #



Zhris
Enthusiast

Apr 9, 2015, 1:35 PM

Post #2 of 2 (5308 views)
Re: [Iconx] What is this called? [In reply to] Can't Post

Hi,

They are called labels, used to label sections or blocks of code and used in conjunction with control statements. They are most useful when dealing with nested loops and you need to refer to an outer loop. In your case, they are used to control the flow of code execution, which in my opinion isn't the best of practices, I prefer to break the blocks up into individual functions with conditional returns.

Chris


(This post was edited by Zhris on Apr 9, 2015, 1:48 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives