exit from subroutine perl
last, next, exit all do not work for exit from subroutine
but return works for exit from subroutine
example
input 12
sub fun {
my $number = shift;
if($number == 12){
print "\n ok bye i am going to outside from subroutine \n";
return;
}
print "\n anop singh ranawat \n";
}
my $number = <>;
&fun($number);
print "\n have a nice day \n";
result
ok bye i am going to outside from subroutine
have a nice day
Comments
Post a Comment