in reply to Re: Don't get the output as expect.
in thread Don't get the output as expect.

Thanks for suggestion I have modified the code
use feature ':5.10'; use strict; use warnings; print "1.Do you want to enter value for Starting account balance. (y/n +)?"; $answer= <STDIN>; chomp $answer; if ($answer eq "y") { print "Please enter SAB= "; $SAB=<STDIN>; print "$SAB"; } print "2.Do you want to enter value date (y/n)?"; $answer= <STDIN>; chomp $answer; if ($answer eq "y") { print "Please enter date= "; $Date=<STDIN>; print "$Date"; } else{ print "Exit"; }
Now i am getting the output what i am expecting

Replies are listed 'Best First'.
Re^3: Don't get the output as expect.
by frozenwithjoy (Priest) on Jun 05, 2013 at 20:38 UTC

    Glad to hear. Be sure to declare your variables with my so that everything will run when you have use strict; in effect.

    Also, you may want to change this:

    if ($answer eq "y")

    to something like this:

    if ( $answer =~ /^y/i )

    That way, it will match Y y Ya yes yup Yar, etc. and let you remove two lines of code since you will no longer need to chomp $answer;.