CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [jeffersno1] perl one liner - need some advice: Edit Log



wickedxter
User

Dec 7, 2011, 5:34 PM


Views: 3769
Re: [jeffersno1] perl one liner - need some advice


Code
 

#!/usr/bin/perl -w

#use strict;
use POSIX;

open ( OUT, ">./results.csv");

$data = "/tmp/tester";

open(LOGFILE,"$data") or die("Could not open log file.");
while ($line = <LOGFILE>) {
$line =~ s/\//,/ if($line =~ /DIA_CCR_U/);
print OUT "$line";
#why are you printing this and creating anouther large file?
}
close(LOGFILE);
close(OUT);


Code
 
Try useing a while loop rather then a foreach, after reading around the web found and article that explained some detail about the deference of the two and the while loop worked the fastest for large files.
http://wildpointer.org/2009/11/15/efficient-reads-on-perl-file-handles-while-vs-foreach/


(This post was edited by wickedxter on Dec 7, 2011, 5:36 PM)


Edit Log:
Post edited by wickedxter (User) on Dec 7, 2011, 5:36 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives