Skip Menu |

This queue is for tickets about the Text-RecordParser CPAN distribution.

Report information
The Basics
Id: 2676
Status: resolved
Worked: 1 min
Priority: 0/
Queue: Text-RecordParser

People
Owner: kclark [...] cpan.org
Requestors: martyn [...] aceshigh.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.02
Fixed in: (no value)



Subject: Not sure that it's really a bug, maybe I just couldn't get it to work
Perl Version 5.6.0 Text:RecordParser version 0.02 Redhat 7.2 2.4.18-10 Simple 4 line "|" delimited file: One|Two|Free|Four Five|Six|Seven|Eight Nine|Ten|Eleven|Twelve Thirteen|Fourteen|Fifteen|Sixten my $p = Text::RecordParser->new(); $p->filename("./test.txt"); $p->field_separator("|"); $p->bind_fields(qw[ field1 field2 field3 field4]); my $record = $p->fetchrow_hashref; print $record->{'Field1'}; this gives "Use of uninitialized value in print at test.pl line 10, <$fh> line 1." If I change the access method to: my $field = $p->extract("Field1"); print $field; this gives "Invalid field Field1 for file './test.txt'. Valid fields are: (Field1, Field2, Field3, Field4 I'm note sure if it's a bug or not, if not have I done something wrong? Thanks, Martyn
[guest - Wed May 28 10:57:48 2003]: Show quoted text
> Perl Version 5.6.0 > Text:RecordParser version 0.02 > Redhat 7.2 2.4.18-10 > > Simple 4 line "|" delimited file: > > One|Two|Free|Four > Five|Six|Seven|Eight > Nine|Ten|Eleven|Twelve > Thirteen|Fourteen|Fifteen|Sixten > > my $p = Text::RecordParser->new(); > $p->filename("./test.txt"); > $p->field_separator("|"); > $p->bind_fields(qw[ field1 field2 field3 field4]); > my $record = $p->fetchrow_hashref; > print $record->{'Field1'}; > > this gives "Use of uninitialized value in print at test.pl line 10, > <$fh> line 1." > > If I change the access method to: > > my $field = $p->extract("Field1"); > print $field; > > this gives "Invalid field Field1 for file './test.txt'. > Valid fields are: (Field1, Field2, Field3, Field4 > > I'm note sure if it's a bug or not, if not have I done something > wrong? > > Thanks, > > Martyn
Martyn, Thanks for the report. You're right, however, that this is not a bug. You are asking for a hashref and getting one back from "fetchrow_hashref." If you happen to reference a key that's not in that hashref, there's nothing Text::RecordParser can do about it. Also, you call "bind_fields" with names "field1," "field2," etc., (with lowercase names), but the warning shows that you must have bound field names like "Field1," "Field2," etc., so that must just be a mistake in what you actually did. This definitely impacts whether you get the warning from Perl on accessing $record->{'Field1'} or $record->{'field1'} HTH, ky