in reply to Re^2: IO::Tee and write / format
in thread IO::Tee and write / format
Had to learn something about formats, I think everything is correct except IO::Tee doesn't handle a string filehandle properly. The formats output fine if selecting STDOUT. SSF#!/usr/bin/perl use strict; use IO::Tee; use IO::String; my $email_body; my $tee = IO::Tee->new(\*STDOUT,new IO::String($email_body)); # crea +te a new tee object and attach STDOUT and the email$ die $! unless $tee; $tee->autoflush(1); my ( $check_description,$check_result,$severity_w ); my $VERSION = 10.0; my $host = "test"; format HEADER = ____v@<<<< @<<<<<<<<<<<_______________________________________________ +______________________________________________ $VERSION, $host Description + Check Result - Status-Severity ______________________________________________________________________ +______________________________________________ . format FAIL = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -ERROR-@> $check_description,$check_result,$severity_w . format STD = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $check_description,$check_result . select STDOUT; $^ = 'HEADER'; # set the top of page format $~ = 'STD'; $check_description = "desc"; $check_result = "result"; $severity_w = "9"; write; print "EMAIL BODY:\n\n$email_body\n"; exit;
|
|---|