Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: how to make this perl code run

by LanX (Canon)
on May 16, 2013 at 16:01 UTC ( #1033859=note: print w/ replies, xml ) Need Help??


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

Well I consider any command line tricks cheating, cause otherwise you could also start calling a recompiled Perl.

Did you try putting the logic in a BEGIN block... (don't know if it does the trick).

But why did you call the OP's script 1.pl? Doesn't make it easier to understand what you are doing...

Cheers Rolf

( addicted to the Perl Programming Language)

PS: I'd try a source-filter approach! =)


Comment on Re^2: how to make this perl code run
Re^3: how to make this perl code run
by choroba (Abbot) on May 16, 2013 at 16:06 UTC
    I tried putting the logic into a BEGIN block, but without success. It is perhaps too late on line 6.

    When testing code samples, I name them 1.pl, 2.pl, 3.pl and so on. The next day, I remove all of them and start again from 1. It is shorter than using the node's id in the name, but still lets me keep several answers ready for improvement if there are objections, which simple junk.pl would not do :-)

    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      This untested code should work ...

      ... BEGIN { sub hi {}; sub hello {}; sub hola {}; }
        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.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        > 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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-11-27 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (178 votes), past polls