in reply to Re^2: perl command line prompts
in thread perl command line prompts

two ways:
if ($answer eq "y") { #this is a string comparison. == is for numbers +only
or (maybe better)
if ($answer =~ /^y/) {
The latter will also work if the user types "yes", "yup", etc.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^4: perl command line prompts
by Transient (Hermit) on May 16, 2005 at 20:28 UTC
    and perhaps even:
    if ($answer =~ /^y/i) {
    To work with "Yup", "Yes", "yay" and "yak"