in reply to Re: Returning all data from subroutine
in thread Returning all data from subroutine

Your question makes no sense. In the code you show there is no point at which you are explicitly returning data from any of your subs and at no point is implicitly returned data from any sub used. Maybe you meant something like:

use warnings; use strict; print addIronman(addAm(addI(""))); sub addI { my ($string) = @_; $string . "i"; } sub addAm { my ($string) = @_; return $string . " am"; } sub addIronman { my ($string) = @_; return "$string ironman"; }

Note that addI returns its result implicitly because the result is the last value evaluated before the implicit return at the end of the sub. The other subs return explicit values.

Perl is the programming world's equivalent of English

Replies are listed 'Best First'.
Re^3: Returning all data from subroutine
by james28909 (Deacon) on Nov 05, 2014 at 03:59 UTC
    i was trying to reason in my post, what would be the reason for returning anything from any sub if it can be dealt with in a sub? i think that is the question i was shooting for even tho my code didnt even show it. hopefully you see what i mean tho. EDIT: very good example code tho.

      It is good programming practice to have such a subroutine report back if it was able to successfully perform its task, or pass back any exceptions or error messages that were generated.

      1 Peter 4:10