Skip Menu |

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

Report information
The Basics
Id: 125384
Status: resolved
Priority: 0/
Queue: Text-CSV-Hashify

People
Owner: jkeenan [...] cpan.org
Requestors: jkeenan [...] cpan.org
Cc:
AdminCc:

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



Subject: Misleading error message when new() gets inappropriate value for 'key'
Consider the two Perl programs attached. They differ only with respect to which element in the Text::CSV::Hashify constructor is live and which is commented-out: ##### $ diff asset-stack-overflow-49471465.pl asa-stack-overflow-49471465.pl 10,11c10,11 < #key => 'asa', < key => 'asset', --- Show quoted text
> key => 'asa', > #key => 'asset',
##### Run the two; 'asset' runs as expected ##### $ perl asset-stack-overflow-49471465.pl ##### But 'asa' dies with a *misleading* error message. ##### $ perl asa-stack-overflow-49471465.pl Key '' already seen at asa-stack-overflow-49471465.pl line 7. ##### The problem is not really that key '' has already been seen. The real problem is that the user supplied key 'asa' which is not found in the header row of attached my_dos.csv. Fix so that the constructor throws an exception if an inappropriate value is supplied for 'key'. As reported by pabloab in https://github.com/jkeenan/text-csv-hashify/issues/4, based on https://stackoverflow.com/questions/49471465/use-of-uninitialized-in-textcsvhashify/49471620#49471620
Subject: asa-stack-overflow-49471465.pl
#!/usr/bin/env perl use 5.14.0; use warnings; use Data::Dumper;$Data::Dumper::Indent=1; use Text::CSV::Hashify; my $obj = Text::CSV::Hashify->new( { file => 'my_dos.csv', format => 'hoh', key => 'asa', #key => 'asset', } ); __DATA__ currency,asset,exchange,strategy,profit,profitday,yearlyprofit,marketchange,profitmarket,tradeamount,tradesday,winingtrades,lossetrades,percentagewins,bestwin,medianwins,worstloss,medianloss,candlesize,warmupperiod,daysofdataset,backteststart,datasetfrom,datasetto,pricevolality,note USD,BTC,bitfinex,BBRSI,0.00,-1,0,-2.55,2.55,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",11.20,"shorter period" USD,XMR,bitfinex,BBRSI,0.00,-1,0,-2.18,2.18,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",17.41,"shorter period"
Subject: asset-stack-overflow-49471465.pl
#!/usr/bin/env perl use 5.14.0; use warnings; use Data::Dumper;$Data::Dumper::Indent=1; use Text::CSV::Hashify; my $obj = Text::CSV::Hashify->new( { file => 'my_dos.csv', format => 'hoh', #key => 'asa', key => 'asset', } ); __DATA__ currency,asset,exchange,strategy,profit,profitday,yearlyprofit,marketchange,profitmarket,tradeamount,tradesday,winingtrades,lossetrades,percentagewins,bestwin,medianwins,worstloss,medianloss,candlesize,warmupperiod,daysofdataset,backteststart,datasetfrom,datasetto,pricevolality,note USD,BTC,bitfinex,BBRSI,0.00,-1,0,-2.55,2.55,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",11.20,"shorter period" USD,XMR,bitfinex,BBRSI,0.00,-1,0,-2.18,2.18,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",17.41,"shorter period"
Subject: my_dos.csv
currency,asset,exchange,strategy,profit,profitday,yearlyprofit,marketchange,profitmarket,tradeamount,tradesday,winingtrades,lossetrades,percentagewins,bestwin,medianwins,worstloss,medianloss,candlesize,warmupperiod,daysofdataset,backteststart,datasetfrom,datasetto,pricevolality,note USD,BTC,bitfinex,BBRSI,0.00,-1,0,-2.55,2.55,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",11.20,"shorter period" USD,XMR,bitfinex,BBRSI,0.00,-1,0,-2.18,2.18,0,-1,0,0,-1,,na,,na,5,144,0,"2018-03-25 01:15:39","2018-03-24 00:00:00","2018-03-24 12:00:00",17.41,"shorter period"