bt1204 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: "require" bug?
by Corion (Patriarch) on Nov 03, 2014 at 10:19 UTC

    When I run your above example, Perl tells me various things that are wrong with it:

    > perl -w 1.pl Unquoted string "colored" may clash with future reserved word at tmp.p +l line 2. Name "main::colored" used only once: possible typo at tmp.pl line 2. print() on unopened filehandle colored at tmp.pl line 2.

    The use Term::ANSIColor; statement happens too late for colored to be interpreted as a function. If you use (for example) parentheses, your intention is clear to Perl:

    print colored(['red'], "test");
Re: "require" bug?
by Corion (Patriarch) on Nov 03, 2014 at 13:55 UTC
Re: "require" bug?
by LanX (Saint) on Nov 03, 2014 at 13:27 UTC
    Please restore the original content of your question. The replies are not understandable anymore.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

Re: "require" bug?
by tobyink (Canon) on Nov 03, 2014 at 21:41 UTC

    "However "require '2.pl'" is before "colored" statement."

    2.pl is loaded before the colored statement is executed, but not before it's compiled. Therefore the Perl compiler doesn't know that colored is a function; it thinks it's a bareword filehandle.

    em
Re: "require" bug? (docs)
by Anonymous Monk on Nov 03, 2014 at 10:22 UTC

    Is that bug and how to fix it?

    If you look up the docs for use and require you can answer that question in about one minute if you're a slow reader