Re: can slurp do this?

Discussion in 'Perl' started by Jürgen Exner, Jul 16, 2008.

  1. Geoff Cox <> wrote:
    >hello
    >
    >Say I am interested in users giving me values for a, b, c and d.
    >
    >I have a file with all the results - a very big file!
    >
    >user 1
    >a: one
    >b: two
    >d: four
    >
    >user 2
    >a: one
    >b: two
    >c: three
    >d: four
    >
    >etc etc
    >
    >and want to create a file
    >
    >user a b c d
    >1 one two x four
    >2 one two three four
    >
    >etc etc
    >
    >How do I put in an x for c for user 1, indicating that this user
    >didn't submit a value for c?
    >
    >I slurping the way to do it?


    No need for slurping in the whole file. If you know the set of all a, b,
    c, d, ... in advance then just go ahead and create the top row. Then
    read in the information for each user and print the row for him.
    If you don't know the set of all a, b, c, ... in advance then read the
    file twice: first pass just to determine the set of a, b, c, ... and the
    second pass as above.

    jue
     
    Jürgen Exner, Jul 16, 2008
    #1
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Stefan Ram
    Replies:
    13
    Views:
    1,856
    Arne Vajhøj
    Jul 27, 2008
  2. Dick Davies
    Replies:
    1
    Views:
    264
    Gavin Sinclair
    Sep 29, 2005
  3. Wes Gamble
    Replies:
    7
    Views:
    298
    Lyle Johnson
    Mar 23, 2006
  4. Helge Elvik
    Replies:
    4
    Views:
    313
  5. Charles R. Thompson
    Replies:
    6
    Views:
    368
    Ben Liddicott
    Jan 13, 2004
  6. Geoff Cox

    slurp not working? ideas please!

    Geoff Cox, Apr 20, 2004, in forum: Perl Misc
    Replies:
    70
    Views:
    879
    Geoff Cox
    Apr 26, 2004
  7. Tom Sliva
    Replies:
    7
    Views:
    356
    Tom Sliva
    Nov 23, 2004
  8. Rhugga
    Replies:
    7
    Views:
    233
    Eric Bohlman
    Feb 9, 2005
Loading...