Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Oct 302010
 

Return the last evaluated statement from function in Perl

Answer:

By default, Perl does not require you to explicit return the the last evaluated statement from function.

E.g.

print function1();

sub function1 {
    my $i = 99;
}

The above program will output 99, and you can see the return statement is not needed and it is a valid Perl program.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>