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" );
Back to
Seekers of Perl Wisdom