Perlfunc: confirm

sub confirm() { my $yes_default = shift(); my $display_text = shift(); my $yes = "y"; my $no = "n"; if ($yes_default) { $yes = uc($yes); } else { $no = uc($no); } $display_text ||= "Confirm"; print "$display_text ($yes/$no): "; chomp(my $confirm = <STDIN>); if (!$confirm) { return $yes_default; } elsif ($confirm =~ /^y/i) { return 1; } else { return 0; } }
Leave A Reply - 2 Replies
Replies
Steven Cole 2006-07-26 10:53pm - stevenaamy1224@super-fast-email.com - Logged IP: 205.145.137.147

I liked your site.

Jim Dobson 2006-10-03 12:50am - ul-Dobson3927@spatzer.com - Logged IP: 206.225.94.28

Your site is very useful.

All content licensed under the Creative Commons License