in reply to read text file and generate an output file with information present in text file.
You are not that far off
#!perl use strict; # <--- add open(my $fh, '<', 'Citytempfile.txt') or die "Cannot open Citytempfile.txt: $!"; # ^^^^ corrected my $i = 0; # ^ missing ; while (<$fh>) { #my @array = split ' ', <$fh> my @array = split ' ', $_; # change print $i+1, '. Temperature in ',$array[0], ' is ', $array[1], ' but average temp in ', $array[2], ' is ', $array[3]," degrees.\n" ; $i++; }
Take a look at using printf
poj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: read text file and generate an output file with information present in text file.
by 2teez (Vicar) on Jan 28, 2016 at 09:34 UTC |