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" );
In reply to Can I break out of a subroutine before the end? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |