Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Don't get the output as expect.

by frozenwithjoy (Priest)
on Jun 05, 2013 at 20:03 UTC ( #1037294=note: print w/replies, xml ) Need Help??

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

The problem with your script is that you are using a single if-elsif-else conditional when you probably need to have a separate conditional for each question or nested ifs (as long as it doesn't get complicated and deep). Also, please use strict;.

Replies are listed 'Best First'.
Re^2: Don't get the output as expect.
by mandalmanas5519 (Initiate) on Jun 05, 2013 at 20:12 UTC
    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

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037294]
[Your Mother]: I prefer palatial fricatives.
[Lotus1]: https://en. wiki/%C3%87
[Your Mother]: I'm headed out west, sucker.
[Lotus1]: the west is the best, get here we'll do the rest
LanX chjuman !
[Eily]: do you pronunce that /xju:mən/ then ?
[Eily]: that's not what I'd call a silent h :)
[LanX]: see soundfile https://en. wiki/human# Pronunciation
[Your Mother]: Just Another Perl 'Acker.
[LanX]: I pronounce it 'juːmən'

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2017-03-27 17:06 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.