in reply to Re: Newbie cmd prompt problem
in thread Newbie cmd prompt problem

Thanks for trying to help. I really appreciate it! re:(a) a new window appear, display some program output (possibly too quickly to read), then disappear; or (b) the window containing the initial command prompt disappear as soon as the program finishes? Both a and b. That is what is so frustrating. Well, that and my brain doesn't think in code. Yes, sometimes it disappears as soon as the program finishes and sometimes nothing happens when I hit enter, no error, it just has the path that I typed. Other times it runs and tells me what lines have errors. Re: your suggestion. I'm only 2 days into this class so I'm not sure what you mean. Here is my code and yes I know there are errors but won't be able to find them until I can run it. Can you add what you were telling me to do so I can try it? #Noel use strict; my $numone; my $numtwo; print "Please enter first number "; $numone=<STDIN>; print "Please enter second number "; $numtwo=<STDIN>; if ($numone < $numtwo); { print $numone; print $numtwo; } elsif { print $numtwo; print $numone; }

Replies are listed 'Best First'.
Re^3: Newbie cmd prompt problem
by kcott (Archbishop) on Sep 12, 2013 at 01:00 UTC
    "Thanks for trying to help. I really appreciate it! ..."

    While I'm happy to help, you need to help us as well. Posting all your text and code in a single block without any markup makes it very difficult to read. Put your text into paragraphs within <p>...</p> tags and your code within <code>...</code> tags. Details can be found in (or linked from) "Writeup Formatting Tips"; and "How do I change/delete my post?" explains how to fix what you've already done.

    After putting your code into some sort of readable layout, it would appear that what I'm talking about is pretty much the same thing that you're learning about:

    $ perl -Mstrict -Mwarnings -E ' my $numone; my $numtwo; print "Please enter first number "; $numone = <STDIN>; print "Please enter second number "; $numtwo = <STDIN>; #if ($numone < $numtwo); { <--- WRONG: no semicolon here if ($numone < $numtwo) { print $numone; print $numtwo; } # elsif { <--- WRONG: should be else else { print $numtwo; print $numone; } print "Hit enter when done: "; <>; ' Please enter first number 456 Please enter second number 123 123 456 Hit enter when done:

    So, in this context, "<>" is just a short-hand form of "<STDIN>": see "perlop: I/O Operators" for the full story. Also, I don't assign the user input to a variable because I don't want it and, in fact, don't really care what the user enters. This works the same:

    $ perl -Mstrict -Mwarnings -E ' ... previous code unchanged ... print "Hit enter when done: "; <STDIN>; ' Please enter first number 456 Please enter second number 123 123 456 Hit enter when done: I'm all done with this!

    -- Ken

Re^3: Newbie cmd prompt problem
by nquiton (Novice) on Sep 12, 2013 at 00:10 UTC
    clearly I don't know how to insert my code. Yicks.