in reply to Re: Subroutines vs Modules
in thread Subroutines vs Modules
With output:#! /usr/bin/perl use strict; use warnings; #//////////////////////////////////////// sub whoami { print "Just entered subroutine ", (caller(1))[3], "\n"; return; } #//////////////////////////////////////// sub one_times_two { whoami(); my( $one, $two ) = @_; return $one * $two; } #//////////////////////////////////////// my $one = 12; my $two = 10; my $three = one_times_two( $one, $two ); my $four = 2 * $three; print "2 x $three = $four\n"; exit 0;
Note: I beleive you need Perl 5.6 or greater for "use warnings".Just entered subroutine main::one_times_two 2 x 120 = 240
-- Argel
|
|---|