#!/usr/bin/perl use strict; use warnings; sub confirm{ my $question=shift; my $reply = ""; print "$question (y/n)?"; while ($reply !~ m/^[yn]/i){ # allow for pedants who reply "yes" or "now" chomp($reply=); } return $reply=~m/^y/i ? 1 : undef; } print confirm("can you write device drivers")?"wow, you must be very skilled\n":"neither can i, i am just shell script\n";