in reply to Can't use string

use diagnostics can be helpful when diagnostic messages seem cryptic.

Be well,
rir

Replies are listed 'Best First'.
Re^2: Can't use string
by ikegami (Patriarch) on Feb 01, 2008 at 11:56 UTC

    I didn't know it worked for strict errors (or any other errors), so I tried it out. Turns out the diagnostic is even more cryptic than the original message, and misleading in mentioning references in what it usually a need to use a hash or array.

    >perl -e"use diagnostics; use strict; print ${'x'}" Can't use string ("x") as a SCALAR ref while "strict refs" in use at - +e line 1 (#1) (F) Only hard references are allowed by "strict refs". Symbolic references are disallowed. See perlref. Uncaught exception from user code: Can't use string ("x") as a SCALAR ref while "strict refs" in +use at -e line 1. at -e line 1