in reply to Re^2: use of $sub
in thread use of $sub

I would like to understand the addition of "$"

Not, "$" but "$!". The exclamation mark is not just for decoration. See perlvar.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^4: use of $sub
by JimLS (Novice) on Oct 19, 2012 at 15:57 UTC

    Not, "$" but "$!".

    No, I don't mean "$!". I looked up "$!" and understood that. I mean the addition of "$" to "SUB" resulting in "$SUB".

      Oh OK. $SUB is just a variable... same idea as $TUB or $PUB or $RUB... nothing special. In this case it's undefined, so when interpolated into the string doesn't do anything.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
        I could be way off base but I was thinking that $SUB (or SUB) was used in an attempt to report where in the program/which subroutine the error occured and was a predefined thing. If not, it must have been set in other parts of the program that this chunk of code may have been pulled out of. In any case I don't need it and will delete it. Thanks!