Excuse me for the missing attachments. As I composed the mail in gmail which is not recognised on the mailing list. The attachments are now included.
----- Original Message ---- From: "Roode, Eric" <ero...@barrack.com> To: activeperl@listserv.activestate.com Cc: zilore mumba <zmu...@yahoo.com> Sent: Tue, September 21, 2010 4:36:19 PM Subject: RE: Reading a line as an array On Tuesday, September 21, 2010 11:27 AM, zilore mumba wrote: > Hello Perl Community, > This mail was posted on gmail but may have been vetted by the moderator. > firstly my apologies for 1) a very basic question, 2) something I > should do in C. > 1. I have rainfal data (attached as sample.txt) month by month in > mixed float and integer which I cannot handle in fortran. I need to > first rewrite the data all in real (float) before I can use fortran. > 2. The perl script I have written read line by line, but then how do I > split the line into 31 values? > 3. as it is, the script rewrites each line and does not change any int > into float, I tried printf (with format) it doesn't work. > Is it possible? > Assistance will be appreciated. > Zilore Hello. You should not consider doing this in C. It would be a lot more work, and give you no benefit over doing it in Perl. Your attachment did not reach the mailing list. Perhaps you could post it online somewhere, and provide a link to it? Or try sending it to the list again? In general, you will probably want to: Read each line into a string (via the -n command-line option, or via the "diamond operator" <>) Split each line into an array of values (via the -F command-line option, or the split() operator) Reformat each value, and output them (via printf). So it looks like you have the right idea. Please try sending the attachment again, and also please let us see what perl code you have tried so far. Yours, Eric Roode _______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
write_rn.pl
Description: Binary data
KIGALI AERO Rainfall (mm) LAT:01ø 58 LON:030ø 08 "Alt:1,490.0" Date 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1971 01 11.8 0.4 0 0 0 0 0 0 0.1 0 2.9 0 9.4 0.3 0.2 0 0 0 0 1.7 0 0 0 0 0 0 0 0.5 0 0 8.1 1971 02 4.3 2.2 0.6 5.9 3 3.3 0 10.7 0 0 0 0 0 0 0 15.3 0 0 0 1.7 0 8.8 0 3.2 0 0 0 7.3 1971 03 0 0 0 0 0 0 0 0 0 1.1 0 0 3 0 2.9 0.5 5.7 0 6.6 0 0.1 0 0 0 0.9 10.5 2.4 25.1 11 13 2.1 1971 04 1.6 18.4 0 0.7 8.8 0.8 1.3 0 2.7 7 0.1 20 25.3 0.6 2.7 4 0 4.8 0.1 3.6 10.2 12.9 1.8 0 36.2 0.1 0 0.1 1.6 0 1971 05 0 10.9 2.1 0 2.3 8.1 0.3 4.4 1.4 0 0 4.3 0 21.9 5.6 0.9 4 0 17.4 0 29.3 11.3 0.6 0 0 0 0 0 0 0 4.2 1971 06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1971 07 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 1 0.3 0.1 2.5 1 0.3 0 0 0 0 1.4 0.3 0 0 0 0 1971 08 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.9 0 1 0 5.3 0 45.1 0 0 0 0 2.8 1971 09 0 0 0 17 0 3.5 1.9 0 0 0 0 31.6 1.9 0.9 0.1 2.3 0 0.5 0 0 0 0 0 0 0 4.8 13.7 0 0.7 0.5 1971 10 2.4 0.5 2.5 0 0 0.3 0 0 16.5 0 4.3 5.5 0 0 0 0 0 0.3 11 5.3 0 0 1.5 0 0 3.6 0.8 1.9 0.2 0 0 1971 11 1.3 13.2 0 0 0 0 0.3 0 4.6 0 0 0.9 11.5 5.4 0 25.5 0 29.7 0.5 0 1 1.8 0 3.6 2.2 0.6 14.6 8.6 0 0 1971 12 6.3 5.3 1 0 0 0 0 0 0 1.8 0 0 0 0 0 6.7 4.5 0 0 0 0 0 0 4.2 21.9 0 0 28.3 0 10.3 2.5
_______________________________________________ ActivePerl mailing list ActivePerl@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs