Reputation: 317
I am facing the error "Undefined subroutine &main::header called at /opt/alu-rp/www/cgi/munin-cgi-html line 54." while opening the munin page(http://localhost/munin)
Perl version: v5.32.0 Munin version: v2.0.65
With the error, able to see the header is not initiated due to the new condition added in munin-cgi-html
# grab config
html_startup(\@params);
while(new CGI::Fast){
print header("text/html");
$config = get_config(1);
show_page();
}
:
:
# CGI in perl 5.20 is now seriously broken as it doesn't import into the namespace.
# So we have to delegate explicitly. It's easier than prefixing with CGI:: each use.
# This workaround is applied only if "header" is undefined (i.e. for perl >= 5.20).
if(!defined &header){
*header = sub { return CGI::header(@_); };
*path_info = sub { return CGI::path_info(@_); };
*url = sub { return CGI::url(@_); };
*script_name = sub { return CGI::script_name(@_); };
}
Adding a line in munin-cgi-html able to solve the issue.
sub header { return CGI::header(@_); }
But not sure what will be the impact of adding this line. Is there anything specific configuration or package needs to install for Munin to work?
Upvotes: 2
Views: 896
Reputation: 385915
The block on the bottom is importing symbols from CGI. Unfortunately, you are trying to use header
before executing this block to import it. You need to execute the imports before all uses of header
and such.
Note that
*header = sub { return CGI::header(@_); };
is better written as
*header = \&CGI::header
as it avoids a needless extra sub call.
Note that you can ask CGI.pm to export those symbols for you. Instead of manually importing the symbols, you can simply use either of following:
use CGI qw( header path_info url script_name );
use CGI qw( :cgi );
No need to clunckily import the symbols yourself.
Upvotes: 4