#!/usr/bin/perl use strict; use warnings; use CGI (); my $cgi = CGI->new(); my $infile = '/path/to/file.html'; open my ($fh), '<', $infile or die "Couldn't open $infile! $!"; read $fh, my ($html), -s $infile or die "Couldn't read $infile! $!"; close $fh or die "Couldn't close $infile! $!"; my $generated_password = function_to_generate_password(); $html =~ s/some_special_target_in_your_html_file/$generated_password/sgi; print $cgi->header(); print $html;