thanks for the help - im looking up hash slices - but id like to get
something that works and then i can add new ideas etc so im going to
leave it as it for the time being.
Data::Dumper has helped sort out where an error is coming
#!/usr/bin/perl -w
use strict;
use warnings;
open O, "<$file" or die "could not open $file - $!";
undef $/;
my $whole_file = <O>;
close O;
$whole_file=~s/\x0D\x0A1/\x0D\x0AABC1/g;my @rows=split(/\x0D\x0AABC/,
$whole_file);
######splits in the correct place after looking at the CSV file with a
hex editor - ugly but it seems to work ATM######
my %hash;
my @headings=split(/,/,$rows[0])
for (my $j=1;$j<=2;$j++)
{
my @columns = $csv->fields ();
for (my $i=0;$i<=$#columns;$i++) {$hash{$headings[$i]}=$columns[$i];}
print Dumper(%hash);
push (@{$Hofdates{$hash{OPDATE}}},\%hash);
print Dumper (%Hofdates);
}
and i get this output
#############1st record
$VAR1 = 'STANTIME';
$VAR2 = '06:04';
$VAR3 = 'T3_AN2no';
$VAR4 = '';
$VAR5 = 'DESC3';
$VAR6 = '';
$VAR7 = 'T1_ANSNAME';
etc etc to the end
then
-----------------01/10/2006---BROWN---------------
$VAR1 = '01/10/2006';
$VAR2 = [
{
'STANTIME' => '06:04',
'T3_AN2no' => '',
'DESC3' => '',
'T1_ANSNAME' => 'SMITH',
'P3_STANDTIME' => '',
'T2_AN2name' => '',
<snip>
'CANCREASON' => '',
'RN2_NO' => '',
'T2_SUSDuty' => ''
}
];
#######################2nd record from file
$VAR1 = 'STANTIME';
$VAR2 = '17:39';
$VAR3 = 'T3_AN2no';
$VAR4 = '';
$VAR5 = 'DESC3';
$VAR6 = '';
<snip>
$VAR347 = 'CANCREASON';
$VAR348 = '';
$VAR349 = 'RN2_NO';
$VAR350 = '';
$VAR351 = 'T2_SUSDuty';
$VAR352 = '';
------------------01/10/2006---JONES--------------
$VAR1 = '01/10/2006';
$VAR2 = [
{
'STANTIME' => '17:39',
'T3_AN2no' => '',
'DESC3' => '',
'T1_ANSNAME' => '',
'P3_STANDTIME' => '',
'P4_OPCS4_3' => '',
'STANDATE' => '01/10/2006',
'CANCREASON' => '',
'RN2_NO' => '',
'T2_SUSDuty' => ''
},
$VAR2->[0]
];
grenada tmp #
so its pushing the second hash onto the array and overwriting the
1st
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/