|
|
| Problems? Is your data what you think it is? | |
| PerlMonks |
Re: Use of BEGIN blockby pfaut (Priest) |
| on Apr 27, 2025 at 15:28 UTC ( [id://11164835]=note: print w/replies, xml ) | Need Help?? |
|
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.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||