Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
redirected to a files. Then I am taking the difference of two files(first file after removing the 4th field and .xml) The difference of the lines is passed as <FILE2>.#!/usr/bin/perl $data_file="/tmp/input_ext_id.txt"; open(DAT, $data_file) || die("Could not open file!"); @datas=<DAT>; foreach $data(@datas){ $data_orig=$data; @data=split("/",$data); $data[4] =~ s/\.xml//ig; chomp($data_orig); push(@finalarr,"$data_orig#$data[0]/$data[1]/$data[2]/$data[4]"); push(@finalarr, "$data[0]/$data[1]/$data[2]/$data[4]"); } @sorted_list = sort(@finalarr);
When the files contains the line of 230K, it takes too long time and prints out the message "OUT of memory" The output should print@datas=<FILE2>; while ($line = <FILE1>) { $position=rindex($line,"#")+1; $lines = substr($line,$position); #print $lines; $lines =~ s/^\s//gi; if ( grep( /$lines/,@datas) ) { print "$line"; }
2002/04/01/bbb/abc.xml
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read the two files
by GrandFather (Saint) on Jul 22, 2009 at 11:45 UTC | |
|
Re: Read the two files
by jethro (Monsignor) on Jul 22, 2009 at 11:44 UTC | |
|
Re: Read the two files
by rovf (Priest) on Jul 22, 2009 at 11:19 UTC | |
by Anonymous Monk on Jul 22, 2009 at 11:45 UTC | |
by rovf (Priest) on Jul 22, 2009 at 11:46 UTC |