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
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs