sub putHeader { my $db_name = shift; my $header = qq{ $db_name ============== OWNER Table Created }; return $header } #### open my $fh, '|-', 'mailx -s "List report" test@mail' or die "ERROR: Couldn't open pipe: $!"; print $fh $generatedMailText or die "ERROR: Couldn't write to pipe: $!"; close $fh or die "ERROR: Closing pipe failed: $!";