in reply to Attempt to free unreferenced scalar in Copy.pm

Notice that an error will be reported from the line containing an if statement if it occurs anywhere in the controlled block. Accordingly, it's probably _catname, not the if itself, that's giving the trouble.

UPDATE: I thought that this was true, but

perl -e 'if ( 1 ) {' -e '1/0' -e '}'
reports "Illegal division by zero at -e line 2", so I guess not. (Also, having looked at the code for _catname, it looks almost as innocuous as the if test itself.)

Replies are listed 'Best First'.
Re^2: Attempt to free unreferenced scalar in Copy.pm
by ikegami (Patriarch) on Oct 29, 2008 at 08:48 UTC

    Runtime errors and warning that occur in the elsif condition were reported as being on the line of the "if".

    >perl580\bin\perl -we"if ( $foo ) {}" -e "elsif ( length($bar) ) {}" Name "main::bar" used only once: possible typo at -e line 2. Name "main::foo" used only once: possible typo at -e line 1. Use of uninitialized value in length at -e line 1.

    I don't know about 5.8.7, but it's was fixed by 5.8.8.

    >perl588\bin\perl -we"if ( $foo ) {}" -e "elsif ( length($bar) ) {}" Name "main::bar" used only once: possible typo at -e line 2. Name "main::foo" used only once: possible typo at -e line 1. Use of uninitialized value in length at -e line 2.

    In any case, that's not the problem here since the if in question doesn't have an elsif clause.