BEGIN …; in Perl [on hold]
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have a perl-script:
#!/usr/bin/perl
BEGIN
print "That's BEGIN messagen";
BEGIN print "That's BEGIN-2 messagen"; ;
END print "That's END messagen"; ;
BEGIN print "That's BEGIN-3 messagen"; ;
;
It works so:
That's BEGIN-2 message
That's BEGIN-3 message
That's BEGIN message
That's END message
But why? It must prints in line 1 That's BEGIN message
or no?
perl
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Rui F Ribeiro, RalfFriedl, schily, John WH Smith, DarkHeart 2 days ago
- This question does not appear to be about Unix or Linux within the scope defined in the help center.
add a comment |Â
up vote
3
down vote
favorite
I have a perl-script:
#!/usr/bin/perl
BEGIN
print "That's BEGIN messagen";
BEGIN print "That's BEGIN-2 messagen"; ;
END print "That's END messagen"; ;
BEGIN print "That's BEGIN-3 messagen"; ;
;
It works so:
That's BEGIN-2 message
That's BEGIN-3 message
That's BEGIN message
That's END message
But why? It must prints in line 1 That's BEGIN message
or no?
perl
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Rui F Ribeiro, RalfFriedl, schily, John WH Smith, DarkHeart 2 days ago
- This question does not appear to be about Unix or Linux within the scope defined in the help center.
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a perl-script:
#!/usr/bin/perl
BEGIN
print "That's BEGIN messagen";
BEGIN print "That's BEGIN-2 messagen"; ;
END print "That's END messagen"; ;
BEGIN print "That's BEGIN-3 messagen"; ;
;
It works so:
That's BEGIN-2 message
That's BEGIN-3 message
That's BEGIN message
That's END message
But why? It must prints in line 1 That's BEGIN message
or no?
perl
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a perl-script:
#!/usr/bin/perl
BEGIN
print "That's BEGIN messagen";
BEGIN print "That's BEGIN-2 messagen"; ;
END print "That's END messagen"; ;
BEGIN print "That's BEGIN-3 messagen"; ;
;
It works so:
That's BEGIN-2 message
That's BEGIN-3 message
That's BEGIN message
That's END message
But why? It must prints in line 1 That's BEGIN message
or no?
perl
perl
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Sep 8 at 21:33


misdeed
1517
1517
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
misdeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
put on hold as off-topic by Rui F Ribeiro, RalfFriedl, schily, John WH Smith, DarkHeart 2 days ago
- This question does not appear to be about Unix or Linux within the scope defined in the help center.
put on hold as off-topic by Rui F Ribeiro, RalfFriedl, schily, John WH Smith, DarkHeart 2 days ago
- This question does not appear to be about Unix or Linux within the scope defined in the help center.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
9
down vote
accepted
The first BEGIN
isn't run until it is completely defined (see documentation). That doesn't happen until the end of the last }
.
The others get run as they're completely defined — earlier.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
accepted
The first BEGIN
isn't run until it is completely defined (see documentation). That doesn't happen until the end of the last }
.
The others get run as they're completely defined — earlier.
add a comment |Â
up vote
9
down vote
accepted
The first BEGIN
isn't run until it is completely defined (see documentation). That doesn't happen until the end of the last }
.
The others get run as they're completely defined — earlier.
add a comment |Â
up vote
9
down vote
accepted
up vote
9
down vote
accepted
The first BEGIN
isn't run until it is completely defined (see documentation). That doesn't happen until the end of the last }
.
The others get run as they're completely defined — earlier.
The first BEGIN
isn't run until it is completely defined (see documentation). That doesn't happen until the end of the last }
.
The others get run as they're completely defined — earlier.
answered Sep 8 at 21:41


Thomas Dickey
49.9k586155
49.9k586155
add a comment |Â
add a comment |Â