catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:
I am taking a file and trying to create report Data is Name Street Zip and I want each to appear on it's own line: Name: Fred Street: Green Zip 55505 Below is the code and error message.
#! /usr/bin/perl use v5.16.3; use strict; use warnings; use diagnostics; ######################################################### ## # ## 9/4/20 # ## Program takes white space separated values and # ## produces a report for each line # ## # ## # ######################################################### chomp( my $header = <> ); my @field_names = split /\s+/, $header; while( <>) { chomp; my @fields = split /\s+/; foreach my $index (0 .. $#fields ) { print "$field_names[$index]: $fields[$index]\n" } } Use of uninitialized value within @field_names in concatenation (.) or + string at ./Exercise_9_6.pl line 26, <> line 3 (#1)
TIA The Catfish </post>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Creating report
by davido (Cardinal) on Sep 08, 2020 at 20:12 UTC | |
Re: Creating report
by Fletch (Bishop) on Sep 08, 2020 at 19:29 UTC | |
Re: Creating report
by tobyink (Canon) on Sep 08, 2020 at 19:29 UTC |