use warnings; use strict; my $x = <>; my $y = "X" if $x =~ /X/; $y = "Z" if !defined $y; print "$y\n";