#!/usr/bin/perl use strict; use warnings; my ($string); while($string ne 'exit') { $string = ; last if $string =~ /exit/; }