in reply to Re: I'm getting some weird error
in thread I'm getting some weird error

Thank you! Yes, that works now. But I don't understand why mine didn't work. It was saying
printList was called. Hey, I am from Italy! 1 2 3 4 Can't use string ("1") as a subroutine ref while "strict refs" in use +at C:\DESKTOP\test.pl line 16. Press any key to continue . . .

I wasn't trying to use "1" as a sub ref. What is that all about???

Replies are listed 'Best First'.
Re^3: I'm getting some weird error
by Corion (Patriarch) on Dec 05, 2018 at 08:13 UTC

    You called your subroutine, and then tried to call its result again, as a subroutine:

    &$subref; # this calls the subroutine &$subref->(); # this calls the subroutine and tries to call the result + again, as a subroutine

    Using & is a bad idea in most cases.

Re^3: I'm getting some weird error
by LanX (Saint) on Dec 05, 2018 at 12:28 UTC
    Perl offers two ways to dereference (most) datatypes.
    • with the right sigil like &$code_ref(ARGS)
    • with a deref arrow + bracket $code_ref->(ARGS)
    Same for hashes and arrays.

    You mixed both (and Corion explained what happend)

    See perlreftut and References quick reference for more.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice