- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
BEGIN and END Blocks in Perl
You may define any number of code blocks named BEGIN and END in Perl programs, which act as constructors and destructors respectively.
BEGIN { ... } END { ... } BEGIN { ... } END { ... }
- Every BEGIN block is executed after the perl script is loaded and compiled but before any other statement is executed.
- Every END block is executed just before the perl interpreter exits.
- The BEGIN and END blocks are particularly useful when creating Perl modules.
Following example shows its usage −
Example
#!/usr/bin/perl package Foo; print "Begin and Block Demo\n"; BEGIN { print "This is BEGIN Block\n" } END { print "This is END Block\n" } 1;
Output
When above code is executed, it produces the following result −
This is BEGIN Block Begin and Block Demo This is END Block
- Related Articles
- map::begin() and end() in C++ STL
- set::begin() and set::end() in C++ STL
- vector::begin() and vector::end() in C++ STL
- list begin( ) and list end( ) in C++ STL
- forward_list::begin() and forward_list::end() in C++ STL
- deque::begin() and deque::end in C++ STL
- match_results begin() and end() function in C++ STL
- multiset begin() and end() function in C++ STL
- multimap::begin() and multimap::end() in C++ STL
- If$begin{bmatrix}x 3\ 0 2y-xend{bmatrix} +begin{bmatrix}1 2\ 0 -2end{bmatrix} =begin{bmatrix}4 5\ 0 3end{bmatrix}$.Find the value of x and y.
- How can we create MySQL stored procedures without ‘BEGIN’ and ‘END’?
- Use delimiter correctly in a MySQL stored procedure to avoid BEGIN/END statements errors
- If the additive inverse of the matrix $displaystyle begin{bmatrix}a-2 & b\ 1 & 3end{bmatrix}$ is $displaystyle begin{bmatrix}2 & 0\ -1 & -3 end{bmatrix}$. Find the values of a and b.
- If $displaystyle P = begin{bmatrix}2 & 4\ 3 & 5end{bmatrix} and Q = begin{bmatrix}-2 & 2\ 4 & 1end{bmatrix}$ , find the marix R such hat $P - Q + R$ is an Identity matrix.
- Return a boolean array where the string element in array ends with a given suffix but test begin and end in Python

Advertisements