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

This works as specified. No need to nest the blocks.
print "1. Do you want to enter value for Starting account balance. (y/ +n)?\n"; chomp(my $answer = <STDIN>); my $SAB; if ('y' eq $answer) { print 'Please enter SAB='; $SAB = <STDIN>; } print "2. Do you want to enter the Date (y/n)?\n"; chomp($answer = <STDIN>); exit if 'n' eq $answer;

However, you have not specified what to do if the user entered something else.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ