I've just started programming in perl and have written a few successful scripts but had a quick question on how to do 2 things.
First here is a script that I wrote recently that works for what it is supposed to do, but is not quite what I want.
Basically what I need to do is to extract the nth character of each line beginning with 'cere' and push the output of that into an array. I will repeat that for some other strings as well. Then from there I need to be able to only print n characters per line so that I can say print 100 cere characters, then 100 a characters, then 100 b characters in a format similar to this:
cere-xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxx
aaaa-yyyyyyyyyyyyyyy yyyyyyyyyyyyyyy yyyyyyyyyyyy
bbbb-zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzz
any help is greatly appreciated!
First here is a script that I wrote recently that works for what it is supposed to do, but is not quite what I want.
Code:
#!/usr/bin/perl
$file_q = "x.txt";
open(FILE, $file_q)||die "nope\n";
while(<FILE>){
@line = split(/\s+/, $_);
if($line[0]=~/cere/){
push(@wanted_lines,$line[2]);
}}
close (FILE);
print "@wanted_lines\n";
cere-xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxx
aaaa-yyyyyyyyyyyyyyy yyyyyyyyyyyyyyy yyyyyyyyyyyy
bbbb-zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzz
any help is greatly appreciated!
Comment