command line input argv

Discussion in 'Perl Misc' started by pop, May 15, 2006.

  1. pop

    pop Guest

    Hi folks,

    I have a certain output that I display on the terminal at the command
    line and the user should make the choice and I send that output to
    another perl file or throw an error and await output again
    ex

    1. file _one
    2. file_two
    pleae enter your choice : #@$$
    Invalid entry
    Please enter your choice : 1
    <OUTPUT>

    Iam trying to figure out the part from capturing the input and waiting
    on the terminal for him to hit any choice. Can you guys give me a
    pointer on what function is used here to wait. I know I can use argv to
    capture the output.

    How can I print the line "Please enter the choice " and wait for him
    to enter any choice.

    cheers
    pop
     
    pop, May 15, 2006
    #1
    1. Advertisements

  2. pop wrote:
    > I have a certain output that I display on the terminal at the command
    > line and the user should make the choice and I send that output to
    > another perl file or throw an error and await output again
    > ex
    >
    > 1. file _one
    > 2. file_two
    > pleae enter your choice : #@$$
    > Invalid entry
    > Please enter your choice : 1
    > <OUTPUT>
    >
    > Iam trying to figure out the part from capturing the input and waiting
    > on the terminal for him to hit any choice. Can you guys give me a
    > pointer on what function is used here to wait. I know I can use argv to
    > capture the output.
    >
    > How can I print the line "Please enter the choice " and wait for him
    > to enter any choice.


    print 'Please enter your choice: ';
    chomp( my $input = <STDIN> );

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, May 15, 2006
    #2
    1. Advertisements

  3. pop wrote:
    > [...]
    > Iam trying to figure out the part from capturing the input and waiting
    > on the terminal for him to hit any choice. [...]


    my $input = <>;
    print $input . "\n";
     
    Sumo Wrestler (or just ate too much), May 15, 2006
    #3
  4. pop

    pop Guest

    Thanks guys.

    pop.
     
    pop, May 15, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernd Danberg

    main argv command line

    Bernd Danberg, Aug 13, 2004, in forum: C++
    Replies:
    7
    Views:
    24,192
    Rich Grise
    Aug 15, 2004
  2. ern
    Replies:
    2
    Views:
    534
    Walter Roberson
    Aug 17, 2006
  3. Matt
    Replies:
    20
    Views:
    876
    Keith Thompson
    Jul 26, 2007
  4. Chris Allen
    Replies:
    3
    Views:
    475
    Arnau Sanchez
    Aug 29, 2007
  5. Durga B.
    Replies:
    0
    Views:
    384
    Durga B.
    Nov 29, 2010
  6. J Krugman

    [Q] $ARGV, <>, and command-line Perl

    J Krugman, Dec 16, 2004, in forum: Perl Misc
    Replies:
    22
    Views:
    384
  7. Replies:
    1
    Views:
    222
    Felix Geerinckx
    Mar 22, 2005
  8. Niall Macpherson

    ARGV[] unable to pick up command line arguments

    Niall Macpherson, May 19, 2008, in forum: Perl Misc
    Replies:
    7
    Views:
    372
    J├╝rgen Exner
    May 20, 2008
Loading...