biohisham has asked for the wisdom of the Perl Monks concerning the following question:
#works fine sub addem{ ($value1, $value2)=@_; $value1+$value2; print join(':',caller); ($package, $filename, $line)=caller; } $value=addem(2,2); print "\n$value1 + $value2 = $value"; print "\nthe package = $package\n"; print "the file = $filename\n"; print "the line = $line\n";
p.s I am writing this code off a book that I am learning Perl from, it gives concise examples though it is sharp to the point and assumes you have some Perl's background.#not returning anything. sub calling{ $value=addem(2,2); } sub addem{ ($value1, $value2)=@_; $value1+$value2; print join(",", caller 1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting a subroutine's name
by shmem (Chancellor) on Jul 17, 2009 at 17:48 UTC | |
by biohisham (Priest) on Jul 17, 2009 at 18:59 UTC | |
by shmem (Chancellor) on Jul 17, 2009 at 19:20 UTC | |
by biohisham (Priest) on Jul 17, 2009 at 19:52 UTC | |
|
Re: getting a subroutine's name
by repellent (Priest) on Jul 17, 2009 at 18:49 UTC | |
by chromatic (Archbishop) on Jul 17, 2009 at 19:21 UTC | |
|
Re: getting a subroutine's name
by Marshall (Canon) on Jul 17, 2009 at 20:09 UTC |