in reply to Print Vs Return In a Subroutine
I am learning perl recently, but I don`t think that there is some common in statemetns like:
return $someval; print $someval;
They are both doing a different things, however, it`s a bit strange since Larry says that actually return can be omitted so the statement:
sub a { print $variable; } sub b { $variable; }
supposed to have a dafault return statement so I am not sure if sub a is actually returning a print with a parameter or not. Well, as a former C user, I am returning a strings with :
sub a { return sprintf("%s", $_[0]); }
for example... but it`s Perl... there is more than 1 way to do it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print Vs Return In a Subroutine
by wwe (Friar) on Mar 30, 2012 at 11:29 UTC | |
by heatblazer (Scribe) on Mar 30, 2012 at 18:06 UTC | |
by wwe (Friar) on Mar 31, 2012 at 21:49 UTC | |
|
Re^2: Print Vs Return In a Subroutine
by Marshall (Canon) on Mar 30, 2012 at 12:48 UTC |