willperl has asked for the wisdom of the Perl Monks concerning the following question:
A B C D are separated by tab. I would like Perl to capture the C value right before D is larger than 1e-3 (capture Cn-1 when Dn > 1e-3; in this case that would be 3.3E-3), and my code right now looks like this:A B C D 1.0E-1 2.0E-2 3.1E-3 3.0E-9 1.0E-1 2.0E-2 3.2E-3 3.0E-9 1.0E-1 2.0E-2 3.3E-3 3.0E-9 1.0E-1 2.0E-2 3.4E-3 1.0E-1
I don't really know how to process the "capturing Cn-1" part... Would someone please give me some insight? And if I add chomp to my code, the program whined about doesn't return a chomp value, which I don't know the reason. Appreciate to have some insight on chomp, too. Thank you guys!open (linedata, "/test.txt"); while (<linedata>) { ($A, $B, $C, $D) = split(/\t/, $_); print "$A, $B, $C, $D, \n" } close (linedata);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl starter with questions about processing data from a txt file
by choroba (Cardinal) on Jan 17, 2013 at 16:50 UTC | |
by willperl (Initiate) on Jan 17, 2013 at 17:29 UTC | |
by choroba (Cardinal) on Jan 17, 2013 at 17:34 UTC | |
by willperl (Initiate) on Jan 17, 2013 at 22:51 UTC | |
by willperl (Initiate) on Jan 17, 2013 at 23:00 UTC |