Professional Web Applications Themes

Problem with process - Ruby

Hi, can anyone give a hint, why ruby skips the input, when i run this following code? thanks, Markus #!/usr/bin/ruby def search() puts "Suchbegriff: "; search=gets; chop search = $_ search = "Welt"; ARGV.each do |test| File.open("#{test}", "r") do |afile| if (afile.gets =~ /#{search}/i) puts test.to_s end end end end search()...

  1. #1

    Default Problem with process

    Hi,

    can anyone give a hint, why ruby skips the input, when i run this
    following code?

    thanks,
    Markus

    #!/usr/bin/ruby
    def search()
    puts "Suchbegriff: ";
    search=gets;
    chop
    search = $_
    search = "Welt";
    ARGV.each do |test|
    File.open("#{test}", "r") do |afile|
    if (afile.gets =~ /#{search}/i)
    puts test.to_s
    end
    end
    end
    end
    search()



    Markus Blasl Guest

  2. #2

    Default Re: Problem with process

    >>>>> "M" == Markus Blasl <blaslfzi.de> writes:

    M> #!/usr/bin/ruby
    M> def search()
    M> puts "Suchbegriff: ";
    M> search=gets;

    search = $stdin.gets # otherwise ruby read a line from the
    # first file given in argument, and this file
    # is removed from ARGV

    M> chop



    Guy Decoux




    ts Guest

  3. #3

    Default Re: Problem with process


    "Paul Brannan" <pbrannanatdesk.com> schrieb im Newsbeitrag
    news:20030801132057.GT13339atdesk.com...
    > On Fri, Aug 01, 2003 at 09:18:47PM +0900, ts wrote:
    > > search = $stdin.gets # otherwise ruby read a line from the
    > > # first file given in argument, and this
    file
    > > # is removed from ARGV
    >
    > This confused me the first time I saw it, and now I always use
    > $stdin.gets() instead of just gets(). Is there anyone out there who
    > actually uses this feature of Kernel#gets()?
    Yep.

    robert

    Robert Klemme Guest

Similar Threads

  1. Replies: 0
    Last Post: October 18th, 09:18 PM
  2. Replies: 1
    Last Post: February 3rd, 09:30 AM
  3. machine.config process identity problem
    By Allen Davis in forum ASP.NET Security
    Replies: 0
    Last Post: July 29th, 08:27 PM
  4. Batch Process Problem
    By Todd Benrud in forum Macromedia Fireworks
    Replies: 9
    Last Post: February 5th, 08:02 PM
  5. Generic Host Process for Win32 Services problem
    By Bill Todd in forum Windows Networking
    Replies: 0
    Last Post: July 2nd, 10:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139