precision
asked on
Perl File open and read in reverse
Here is what I have...
open (FILE1,"../gt/$in{'id'}/ra fs.txt") || "Can't open filename1 $!";
while( <FILE1> ){
chomp;
my($count,$wa,$id,$n1,$e1, $n2,$e2,$n 3,$e3,$n4, $e4)=split /\|/;
How can I make it open and read from bottom up? I know reverse command, but not sure where to stick it in at.
open (FILE1,"../gt/$in{'id'}/ra
while( <FILE1> ){
chomp;
my($count,$wa,$id,$n1,$e1,
How can I make it open and read from bottom up? I know reverse command, but not sure where to stick it in at.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use File::ReadBackwards ;
tie *FILE1, 'File::ReadBackwards', "../gt/$in{'id'}/rafs.txt" or die "can't read '../gt/$in{'id'}/rafs.txt' $!" ;
while( <FILE1> ) {
chomp;
my($count,$wa,$id,$n1,$e1, $n2,$e2,$n 3,$e3,$n4, $e4)=split /\|/;
tie *FILE1, 'File::ReadBackwards', "../gt/$in{'id'}/rafs.txt"
while( <FILE1> ) {
chomp;
my($count,$wa,$id,$n1,$e1,
ASKER
OZO
That seems like a very efficient way, I tried though and it crashed, I tried a few things but could not make run...
That seems like a very efficient way, I tried though and it crashed, I tried a few things but could not make run...
What did you try and how did it crash?
Do you have File::ReadBackwards installed?
Do you have File::ReadBackwards installed?
open(F, "tac 'filename' |") || die;
while(<F>)
{
print($_);
}
close(F);