use strict; use warnings; while(my $input = ){ die "User requested exit" if $input eq 'exit'; #do whatever... }