Reaction is that it will only take the last line and print it in front of the file and then generate a lots of empty lines. Can anybody help me with this code or suggest a better one. JP Updated. Thanks for your replys. I found a module File::ReadBackwards that soothed all my problems in a sec :D Though im still curious whats the problem with my original code. And no it is not somekind of a programming homework - I have to work with several bioinformatics programs for my thesis, and being academic software they are usually not at all meant for compability. So i have to reformat outputfiles from some of them to use as input files for others. Sometimes the formatting differences are small and easy, sometimes differences are large but solutions are easy and this time the difference was small ( reverse the file) but solution just dindt came to my mind :D Also files tend to be in several Gb-s so any solutions involving reading those files in memory are out. ( makes my life harder)#!/usr/bin/perl -w use strict; use warnings; my $file = 'hugefiletobereversed'; open FH, 'hugefiletobereversed'; while (our $newline = <FH>) { { local @ARGV = ($file); local $^I = '.bac'; while(<>){ if ($. == 1) { print "$newline\n"; } else { print; } } } }
In reply to reversing files line by line by naturalsciences
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |