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

Re^2: Template to create modules

by guiwp (Sexton)
on Jun 15, 2016 at 00:04 UTC ( [id://1165662]=note: print w/replies, xml ) Need Help??


in reply to Re: Template to create modules
in thread Template to create modules

Looking at the examples given surprise me one thing: just one of the samples gave me this "BEGIN" and "END" (the one provided through the perlmod).

I've read now one article about this thing called BEGIN and it says on one comment:

"You didn't mention that BEGIN blocks even run when syntax checking with perl -cw. That's always seemed worrying on a security basis to me - I'm checking the syntax of the program, not running it! What if the BEGIN block does system( "rm -rf ...")?"

So trust on code that has this feature is a bit dangerous when you want to just syntax check...

For the curiosity I've checked if the library that I'm using to learn perl use this feature and it doesn't! (see here).

Replies are listed 'Best First'.
Re^3: Template to create modules
by choroba (Cardinal) on Jun 15, 2016 at 07:56 UTC
    > I've checked if the library that I'm using to learn perl use this feature and it doesn't!

    Sure it does. You need to follow the use clauses, line #11 says

    use JSON;

    which in turn, on line #9, says

    BEGIN {

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found