Ganesh Bharadwaj1 has asked for the wisdom of the Perl Monks concerning the following question:
I want to print out something likeJakarta 30 indonesia 40 Beijing 50 China 20
I am not sure how to save the 4 words and split them using delimiter so that I can actually use them somewhere. I think I am way off in the coding part, since I am new to perl. This is what I wrote, but this doesnt work.1. Temperature in Jakarta is 30, but average temp in indonesia is 40 d +egrees. 2. Temperature in Beijing is 50, but average temp in China is 20 degre +es.
open(my $fh, '<', 'Citytempfile.txt') or die "Cannot open cellnames.txt: $!"; my $i = 0 while (<$fh>) { my @array = split ' ', <$fh> print $fileHandle_drc $i+1, 'Temperature in ',$array[0], ' is ', $arr +ay[1], 'but average temp in ', $array[2], 'is', $array[3] ; $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: read text file and generate an output file with information present in text file.
by poj (Abbot) on Jan 28, 2016 at 09:25 UTC | |
by 2teez (Vicar) on Jan 28, 2016 at 09:34 UTC | |
|
Re: read text file and generate an output file with information present in text file.
by thomas895 (Deacon) on Jan 28, 2016 at 09:23 UTC |