in reply to Interactive Perl script
BTW: the Dublin Perl mongers group is holding a re-inauguration at OSBarCamp, feel free to come along.#!/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=<STDIN>); } return $reply=~m/^y/i ? 1 : undef; } print confirm("can you write device drivers")?"wow, you must be very s +killed\n":"neither can i, i am just shell script\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interactive Perl script
by Irishboy24 (Sexton) on Aug 27, 2009 at 16:02 UTC | |
by Utilitarian (Vicar) on Aug 27, 2009 at 20:21 UTC |