CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Use of uninitialized value in hash element at t.pl line 15.

 



abdullah4mi
New User

Dec 12, 2014, 2:32 AM

Post #1 of 3 (1239 views)
Use of uninitialized value in hash element at t.pl line 15. Can't Post

#!/usr/bin/perl
use Data::Dumper;
use warnings;
my %tHash=();

my @tARR;
$info = "<OfferList><Offer><OfferId>2018</OfferId><OfferExpiryDate></OfferExpiryDate><OfferStartDate>20141030</OfferStartDate><OfferType>0</OfferType></Offer><Offer><OfferId>5518</OfferId><OfferExpiryDate></OfferExpiryDate><OfferStartDate>20141110</OfferStartDate><OfferType>0</OfferType></Offer><Offer><OfferId>30274</OfferId><OfferType>2</OfferType><OfferExpiryDateTime>20141128 04.28.13</OfferExpiryDateTime><OfferStartDateTime>20141028 04.28.13</OfferStartDateTime></Offer></OfferList>:UsageCounterUsageThresholdInfoBlob,<UsageCounterUsageThresholdInfos><UsageCounterUsageThresholdInfo><UsageCounterID>3027401</UsageCounterID><UsageCounterValue>2147483648</UsageCounterValue><UsageThresholdInfo><UsageThresholdID>302740101</UsageThresholdID><UsageThresholdValue>2147483648</UsageThresholdValue><UsageThresholdSource>3</UsageThresholdSource></UsageThresholdInfo></UsageCounterUsageThresholdInfo></UsageCounterUsageThresholdInfos>;";
$info =~ s/[<]+/:/g;
$info =~ s/[>]+/,/g;
print $info
@tARR=split(":",$info);
foreach (@tARR)
{ ($tkey,$tvalue)=split(/,/,$_);

push( @{$tHash{$tkey}},$tvalue);

}
for (my $i=0;$i<=6;$i++){
print "@{$tHash{OfferId}}\t@{$tHash{OfferStartDate}}\t@{$tHash{OfferStartDateTime}}\t@{$tHash{OfferExpiryDateTime}}\t@{$tHash{UsageCounterID}}\t@{$tHash{UsageCounterValue}}\t@{$tHash{UsageThresholdValue}}\n";
}

print() on unopened filehandle :OfferList,:Offer,:OfferId,2018:/OfferId,:OfferExpiryDate,:/OfferExpiryDate,:OfferStartDate,20141030:/OfferStartDate,:OfferType,0:/OfferType,:/Offer,:Offer,:OfferId,5518:/OfferId,:OfferExpiryDate,:/OfferExpiryDate,:OfferStartDate,20141110:/OfferStartDate,:OfferType,0:/OfferType,:/Offer,:Offer,:OfferId,30274:/OfferId,:OfferType,2:/OfferType,:OfferExpiryDateTime,20141128 04.28.13:/OfferExpiryDateTime,:OfferStartDateTime,20141028 04.28.13:/OfferStartDateTime,:/Offer,:/OfferList,:UsageCounterUsageThresholdInfoBlob,:UsageCounterUsageThresholdInfos,:UsageCounterUsageThresholdInfo,:UsageCounterID,3027401:/UsageCounterID,:UsageCounterValue,2147483648:/UsageCounterValue,:UsageThresholdInfo,:UsageThresholdID,302740101:/UsageThresholdID,:UsageThresholdValue,2147483648:/UsageThresholdValue,:UsageThresholdSource,3:/UsageThresholdSource,:/UsageThresholdInfo,:/UsageCounterUsageThresholdInfo,:/UsageCounterUsageThresholdInfos,; at t.pl line 10.
Use of uninitialized value in hash element at t.pl line 15.
Use of uninitialized value in hash element at t.pl line 15.
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648
2018 5518 30274 20141030 20141110 20141028 04.28.13 20141128 04.28.13 3027401 2147483648 2147483648


FishMonger
Veteran / Moderator

Dec 12, 2014, 6:22 AM

Post #2 of 3 (1233 views)
Re: [abdullah4mi] Use of uninitialized value in hash element at t.pl line 15. [In reply to] Can't Post

What is your question?


BillKSmith
Veteran

Dec 12, 2014, 6:30 AM

Post #3 of 3 (1229 views)
Re: [abdullah4mi] Use of uninitialized value in hash element at t.pl line 15. [In reply to] Can't Post

The message about an unopened file is the result of the missing semicolon at the end of the first print statement.

The string that you split on semicolon has a semicolon as its first character. Therefore there is no data for the first array element.

Are you sure that you intend to print exactly the same thing six times?
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives