Running a Perl program problem

Help
Z_K
2009-06-19
2013-05-20
  • Z_K
    Z_K
    2009-06-19

    I wrote a very simple perl program and it uses to lines to get standard input twice. The first works okay, but then it just skips right over the second one.  It works fine outside of eclipse from a command box.

    print "Enter several strings on different lines and press Enter and Ctrl-Z to continue.\n";

    chomp(@strings = <STDIN>);

    @strings = sort(@strings);

    print "Do you want the output on seperate lines (Y/N):";

    chomp($choice = <STDIN>);

    if($choice eq "Y" || $choice eq "y")

    This is the ouput:

    Enter several strings on different lines and press Enter and Ctrl-Z to continue.
    hello
    tom
    eeee
    Do you want the output on seperate lines (Y/N):eeee hello tom Use of uninitialized value $choice in chomp at C:/Documents and Settings/Computer/Eclipse/workspace/Perl/Strategy/chap_3_3.pl line 12, <STDIN> line 3.
    Use of uninitialized value $choice in string eq at C:/Documents and Settings/Computer/Eclipse/workspace/Perl/Strategy/chap_3_3.pl line 15, <STDIN> line 3.
    Use of uninitialized value $choice in string eq at C:/Documents and Settings/Computer/Eclipse/workspace/Perl/Strategy/chap_3_3.pl line 15, <STDIN> line 3.