use Win32; use strict; my $output = Win32::MsgBox("Script completed.", MB_ICONINFORMATION); #this part outputs all the time. #conditions here etc.. if(something){ $output; #if this condition is met it outputs and works as it should } else { $output; if this condition is met it outputs and works as it should }