in reply to Just before subroutine returns
Hello solegaonkar,
Try the End module. Here’s a trivial example:
use strict; use warnings; use End; foo(4); foo(6); sub foo { my ($n) = @_; my $x = end { print "\$n = >$n<\n" }; return 1 if $n < 5; $n *= 52; return $n; }
Output:
16:31 >perl 1810_SoPW.pl $n = >4< $n = >312< 16:31 >
Note that the assignment to $x is needed here, because of the way End works, even though the value of $x isn’t used.
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Just before subroutine returns
by karlgoethebier (Abbot) on Aug 29, 2017 at 18:21 UTC | |
Re^2: Just before subroutine returns
by solegaonkar (Beadle) on Aug 29, 2017 at 06:58 UTC | |
by RonW (Parson) on Aug 29, 2017 at 23:39 UTC | |
by LanX (Saint) on Aug 30, 2017 at 00:12 UTC | |
by RonW (Parson) on Aug 30, 2017 at 18:58 UTC |
In Section
Seekers of Perl Wisdom