Hi,
I'm getting the following errror:
Global symbol "$fh" requires explicit package name at
livonia.pl line 22.
Execution of livonia.pl aborted due to compilation errors.
Also can some one suggest a better way to handle the IO I'm
wondering about
the globtype and that is why I used the \*FH in my subroutine.
Below is the code:
#!/usr/bin/perl
# Modules
use strict;
use Text::CSV_XS;
use FileHandle;
# Constants
my $datafile = 'everyone.csv';
#my $summary = 'summary.txt';
#open $handle, "$datafile" or die "$datafile: $!";
sub newopen {
my $path = shift;
local *FH;
open (FH, $path) || return undef;
return \*FH;
}
$fh = newopen("$datafile");
my $csv = Text::CSV_XS->new;
my $column = '';
if ($csv->parse($fh)) {
my @field = $csv->fields;
my $count = 0;
for $column (@field) {
print ++$count, " => ", $column, "\n";
}
print "\n";
} else {
my $err = $csv->error_input;
print "parse() failed on argument: ", $err, "\n";
}
my @sample_input_fields = ('You said, "Hello!"',
5.67,
'Surely',
'',
'3.14159');
if ($csv->combine(@sample_input_fields)) {
my $string = $csv->string;
print $string, "\n";
} else {
my $err = $csv->error_input;
print "combine() failed on argument: ", $err, "\n";
}
#close(INFILE);
#close(OUTFILE);
--
************************************************************
*** Phillip B. Bruce ***
*** http://pbbruce.home.mindspring.com ***
*** [EMAIL PROTECTED] ***
*** ***
*** "Have you ever noticed? Anybody going slower than ***
*** you is an idiot, and anyone going faster than you ***
*** is a maniac." - George Carlin ***
************************************************************