bishop2001 has asked for the wisdom of the Perl Monks concerning the following question:

hi i have a file which contains the following:
11,1428969620,bill<br> 42,1428969618,bob<br> 34,1428969617,joe<br> 55,1428969613,bill<br> 22,1428969614,bob<br>
what id like is:
bill bob joe 1428969620 11 1428969618 42 1428969617 34 1428969613 55 1428969614 22
i have a basic perl ability, but im not sure where to start on this. Thanks

Content restored and Code tags added by GrandFather

Replies are listed 'Best First'.
Re: format file
by hippo (Archbishop) on Apr 16, 2015 at 22:02 UTC

    I'm going to take you at your word, even if it isn't what you meant.

    The algorithm is then:

    1. Open the file
    2. Read a line
    3. Split on commas
    4. Push the 3rd field onto an array
    5. Append the second and first fields to a string, space delimited
    6. Go to 2 unless at EOF
    7. Print the unique array values followed by the string

    Which bits in particular of this algorithm would you have problems with when converting into real Perl code?

    Update: While writing this reply, all content was removed from the OP.

    Update 2: Thanks to GrandFather restoring the original content and now with the code tags it's a little clearer what bishop2001 wants. So, here's a slightly revised algorithm:

    1. Open the file
    2. Read a line
    3. Split on commas
    4. Push the 3rd field onto an array
    5. Concatenate the second and first fields into a string, space delimited
    6. Push that string onto the arrayref value of a hash keyed on the 3rd field
    7. Go to 2 unless at EOF
    8. Print the unique array values.
    9. Loop while there are still data items in one of the HoA fields and print the nth entry in each.

    The question remains: which bits in particular of this algorithm would you have problems with when converting into real Perl code?

Re: format file
by ww (Archbishop) on Apr 16, 2015 at 22:33 UTC

    Just in case janitors are busy right now... here's the OP, verbatim, and set off in a <blockquote </blockquote pair:

    hi i have a file which contains the following:

    11,1428969620,bill
    42,1428969618,bob
    34,1428969617,joe
    55,1428969613,bill
    22,1428969614,bob
    what id like is: bill bob joe 1428969620 11 1428969618 42 1428969617 34 1428969613 55 1428969614 22 i have a basic perl ability, but im not sure where to start on this. Thanks