R
RedGrittyBrick
I've tried various perldoc incantations but haven't yet found where it
is it explained *why* it is necessary to declare subroutines in advance
of using them in order to avoid the following warning messages:
I thought the parentheses would identify the name as a subroutine
invocation.
Can some kind person point out TFM for me to R?
C:\Temp>perl t2.pl
Bareword found where operator expected at t2.pl line 10, near "$html
htmlhead"
(Missing operator before htmlhead?)
Bareword found where operator expected at t2.pl line 12, near "$html
htmltail"
(Missing operator before htmltail?)
C:\Temp>type t2.pl
#!perl
use strict;
use warnings;
# sub htmlhead; # uncommenting these makes the warnings go away.
# sub htmltail;
open my $html, '>', 't.html' or die "unable to open t.html - $!";
print $html htmlhead();
print $html " foo\n";
print $html htmltail();
close $html or die "unable to close t.html - $!";
sub htmlhead {
my $html = <<EndOfHead;
<html>
<head><title>Test</title></head>
<body>
EndOfHead
return $html
}
sub htmltail {
my $html = <<EndOfTail;
</body>
</html>
EndOfTail
return $html
}
is it explained *why* it is necessary to declare subroutines in advance
of using them in order to avoid the following warning messages:
I thought the parentheses would identify the name as a subroutine
invocation.
Can some kind person point out TFM for me to R?
C:\Temp>perl t2.pl
Bareword found where operator expected at t2.pl line 10, near "$html
htmlhead"
(Missing operator before htmlhead?)
Bareword found where operator expected at t2.pl line 12, near "$html
htmltail"
(Missing operator before htmltail?)
C:\Temp>type t2.pl
#!perl
use strict;
use warnings;
# sub htmlhead; # uncommenting these makes the warnings go away.
# sub htmltail;
open my $html, '>', 't.html' or die "unable to open t.html - $!";
print $html htmlhead();
print $html " foo\n";
print $html htmltail();
close $html or die "unable to close t.html - $!";
sub htmlhead {
my $html = <<EndOfHead;
<html>
<head><title>Test</title></head>
<body>
EndOfHead
return $html
}
sub htmltail {
my $html = <<EndOfTail;
</body>
</html>
EndOfTail
return $html
}