Reinventing a square wheel

Discussion in 'Perl' started by Wes Groleau, Aug 21, 2003.

  1. Wes Groleau

    Wes Groleau Guest

    OK, this has probably already been done a hundred times,
    but I wanted to get some practice. But I'm doing something
    wrong and I can't see it.

    File "PickOne" is:

    #!/usr/bin/perl

    @words = <STDIN>;

    $new_word = $words[rand(@words)];

    chomp ($new_word);

    print ($new_word);


    shell command

    ls | PickOne

    has no output. If I use `ls` instead of stdin,
    it does give me one filename each time.
     
    Wes Groleau, Aug 21, 2003
    #1
    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. Replies:
    0
    Views:
    1,402
  2. nicholas
    Replies:
    1
    Views:
    5,258
    Kevin Spencer
    Dec 16, 2004
  3. Morris Dovey

    Re: NUL to terminate strings; was reinventing ASCII?

    Morris Dovey, Mar 8, 2008, in forum: C Programming
    Replies:
    41
    Views:
    1,168
    BruceMcF
    Apr 13, 2008
  4. Willow
    Replies:
    5
    Views:
    386
    James Kuyper
    Mar 13, 2012
  5. jim
    Replies:
    1
    Views:
    121
    beegee
    Oct 27, 2008
Loading...

Share This Page