If I understand you correctly, you have an input file with four fields per line. You want to discard the first two, and join the last two like this "G/A". You then want to print every 90th of these as a new column on each line to produce 90 lines of 301 columns. (I'm ignoring the fact that 90*301 != 10,000 :).

This sample code shows one way to do this...I've done 3 lines of 34 to save a little space:)

#! perl -slw use strict; # Read the file, split into fields, discard the first 2 # join fields 2/3 as required for output. my @data = map{ join '/', (split ' ')[2,3] } <DATA>; my @lines; # Array in which to accumulate the output. # build each output line for my $line ( 0 .. 2 ) { # 0 .. 89 in your app # by steping through the input and appending every nth element to +the output for my $col ( 0 .. 33 ) { # 0 .. 300 in your app $lines[ $line ] .= $data[ $line * 34 + $col ] . ' '; } } # display the output. print for @lines;
__DATA__ 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A 000217 P015 A G 000217 P016 A G 000217 P008 N N 000217 P009 G G 000217 P010 A A 000217 P011 A G 000217 P012 A A 000217 P013 A G 000217 P014 A A

Output

P:\test>junk N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A A/G A/ +G N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A A/G A/ +G N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A A/G A/ +G N/N G/G A/A A/G A/A A/G A/A A/G A/G N/N G/G A/A A/G A/A A/G A/A

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller



In reply to Re: how to use printf correctly... by BrowserUk
in thread how to use printf correctly... by bioinformatics

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.