Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Use of BEGIN block

by pfaut (Priest)
on Apr 27, 2025 at 15:28 UTC ( [id://11164835]=note: print w/replies, xml ) Need Help??


in reply to Use of BEGIN block

Perl has command line arguments that tell it to loop over lines of input (see -n and -p in perlrun). When you use these options your entire program gets executed for each line of input. If you need to perform some initialization before processing any input then the only place it can happen is in a BEGIN block. The END block comes in handy here as a place to print results.

90% of every Perl application is already written.
dragonchild

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2025-12-08 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (88 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.