in reply to reference question yet again
There's a bunch of things you're doing incorrectly:
I'm not sure what output you're expecting, is this program OK?
use Text::CSV_XS; my @data; input (); sub input { my @attrs = qw(_status _gwname _ac_ID_field); my $csv = Text::CSV_XS->new; while ( <DATA> ) { chomp; next if /^START/; $csv->parse($_); my @fields = $csv->fields; my %rec; @rec{@attrs} = @fields; push @data, \%rec; } } foreach my $info (@data) { print "$info->{_status}\n"; } __DATA__ adfadfasdfadsf,"adsf,asdf,adsf",adfasdf adsfasdfasdfasdf,asdfasdfasdf,adsfasdf adsfasdf,"adsf,adsf",adsfadsf "asdfasdf,asdfasdf",adfasdf,asdfasdf
Output:
adfadfasdfadsf adsfasdfasdfasdf adsfasdf asdfasdf,asdfasdf
If you're not already using Data::Dumper, you should be. It'll save you hours of frustration.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reference question yet again
by convenientstore (Pilgrim) on Sep 09, 2007 at 21:35 UTC | |
by almut (Canon) on Sep 10, 2007 at 00:07 UTC | |
by convenientstore (Pilgrim) on Sep 10, 2007 at 01:21 UTC | |
by TGI (Parson) on Sep 10, 2007 at 17:31 UTC |