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; } }


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.15.228.162
To prevent spam please submit by clicking the kitten: