$output = `Command foo`; print $output; if ($output = ~/Do you want to read the file?/) { `2`; print "Correct String detected."; #detects that the if statement was executed. } else { print "Unsuccessful detection of String." #detects that the if statements was unsuccessfully executed. }