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

Hello all, I am trying to concatenate the multiple lines of a multi fasta file into one using the unix command cat file | xargs -n61913917 inside the perl script. But it is giving me the Segmentation fault(core dumped ) error.Any help would be greatly appreciated. Thanks.

Replies are listed 'Best First'.
Re: joining multi lines using xargs
by ikegami (Patriarch) on Mar 12, 2012 at 19:18 UTC

    That's going to mangle your lines anyway. You could use:

    perl -pe'chomp; END { print "\n" }' file

    Update: Forgot about "inside a Perl script". Well, let's avoid launching a new Perl, then.

    open(my $fh_in, '<', $qfn_in) or die("Can't open \"$qfn_in\": $!\n"); open(my $fh_out, '>', $qfn_out) or die("Can't create \"$qfn_out\": $!\n"); while (<$fh_in>) { chomp; print $fh_out $_; } print $fh_out "\n";
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: joining multi lines using xargs
by moritz (Cardinal) on Mar 12, 2012 at 19:11 UTC

      Thanks for the reply but i am trying to join the fasta sequence lines to remove the spaces after each line in the input file for each chromosome in the multi fasta file using the unix command inside the script.However it works for maximum 40000000 lines but if i give 61913917 lines as an argument, it gives me segmentation fault.Thanks