Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: how to make this perl code run

by Anonymous Monk
on May 16, 2013 at 21:25 UTC ( #1033910=note: print w/ replies, xml ) Need Help??


in reply to Re^3: how to make this perl code run
in thread how to make this perl code run

This untested code should work ...

... BEGIN { sub hi {}; sub hello {}; sub hola {}; }


Comment on Re^4: how to make this perl code run
Download Code
Replies are listed 'Best First'.
Re^5: how to make this perl code run
by choroba (Canon) on May 16, 2013 at 21:34 UTC
    Wow, thank you! I did not try this one! It works and gives the expected output:
    Bareword "hi" not allowed while "strict subs" in use at ./1.pl line 3. Bareword "hello" not allowed while "strict subs" in use at ./1.pl line + 4. Bareword "hola" not allowed while "strict subs" in use at ./1.pl line +5. Execution of ./1.pl aborted due to compilation errors.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Any time!

      Besides, I did write "should" & "untested". 0:)

Re^5: how to make this perl code run
by LanX (Canon) on May 16, 2013 at 21:38 UTC
    > This untested code should work ...

    And you think none of us tested this already and we all were too modest to post a code that works???

    8)

    The parser needs to see the declaration before it parses the barewords.

    BEGIN-blocks don't change the parsing order, only the runtime order!

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    to be precise BEGIN-Block are run at parsing time, but the parsing order doesn't change. see perlmod

      Of course (about everybody being modest:>).

      In any case this did remind me of the reason to generate subs in BEGIN block near the very start of a module.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033910]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2015-07-30 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls