aggregate.cgi: slurp file and return scalar

This commit is contained in:
Milan
2022-11-18 00:20:30 +01:00
parent e0106e2a0c
commit 20ab78e6ee

View File

@@ -55,7 +55,6 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
$params = $request->{params}->{checked}; $params = $request->{params}->{checked};
my $content = load_file( $base_dir . './index.html' ); my $content = load_file( $base_dir . './index.html' );
$content = $$content || '';
#replace HTML escaped calcms_title span by unescaped one #replace HTML escaped calcms_title span by unescaped one
$content =~ $content =~
@@ -133,11 +132,11 @@ s/\&lt\;span id\=&quot\;calcms_title&quot\;\&gt\;[^\&]*\&lt\;\/span\&gt\;/\<span
} }
sub load_file { sub load_file {
my $filename = shift; my ($filename) = @_;
my $content = "cannot load '$filename'"; open my $fh, '<:utf8', $filename or return qq{cannot load '$filename'};
open my $FILE, '<:utf8', $filename or return \$content; local $/ = undef;
$content = join( "", (<$FILE>) ); my $content = <$fh>;
close $FILE; close $fh or return qq{cannot load '$filename'};
return \$content; return $content;
} }