Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
You can break out of a subroutine by using the return keyword :
Note that jumping out of the middle of a subroutine is considered bad style by some people who do believe in the statement that every routine should have one entrypoint and one exit.#!/usr/bin/perl -w use strict; sub test { my ($param) = @_; if ($param =~ /e/) { print "e found.\n"; return; }; print "No e found.\n"; }; &test( "test" ); &test( "toast" );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Can I break out of a subroutine before the end?
by AcidHawk (Vicar) on Apr 30, 2003 at 08:20 UTC |
Back to
Seekers of Perl Wisdom