use warnings; use strict; my $x = <>; my $y = "X" if $x =~ /X/; sub x{ print $y ? 'Okay' : 'bad'; } print "$y\n";