in reply to Re^2: Split tab-separated file into separate files, based on column name (updated)
in thread Split tab-separated file into separate files, based on column name

Try changing '>' to '>>'. If I remember correctly, open will silently reopen an already open handle. Since you are using truncating write mode, each file gets truncated every time it is opened.

Replies are listed 'Best First'.
Re^4: Split tab-separated file into separate files, based on column name (solved)
by LanX (Saint) on Aug 28, 2020 at 07:25 UTC
    Hi

    The strange thing is that the "reopened" files are created but all output still goes to the first one.

    Probably a Windows issue...

    Ok got it. I'm pushing new file handles onto the @FH array, but only the first 3 ones are written!

    The trouble with overly clever one liners... 🤦🏻‍♂️

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Try putting open ..., '>', $_ for split scalar <> or similar in a BEGIN block, instead of running it on each loop iteration. :-)