Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AAARRRRRRRRRYYYYYYYY"SSSSS HELP

Status
Not open for further replies.

madaxe2

Technical User
Jan 23, 2005
43
US
Trying to increment a specific value on a specific line in an array by 1 everytime the page is viewed.

My code does not error but it does not work

MADAXE

Code:
foreach my $moddata2 (@data2) {
chomp $moddata2;
my ($TTITLE3,$COMMENT3,$NOPOSTS3,$PUSER3,$LOOKS3,$DATE3,$VUSER3,$ICON3,$tlink3) = split(/\|/, $moddata2);


		if ($TTITLE eq $TTITLE3) {
		$LOOKS3 += 1; 
		
	}
}

open (INF2, ">$dbdata2") || die qq(Can't open "$dbdata2" for write!\n);    
print INF2 join("\n", @data2), "\n";
close(INF2) || die qq(Can't close "$dbdata2" after write!\n);
 
($TTITLE eq $TTITLE3)

where's $TTITLE coming from and does it need to be chomped for the two to be equal
Code:
open LOG ">>logfile.txt";
print LOG "[$TTITLE][$TTITLE3]\n";
close LOG;
put this in just before you compare the two and see what you get

HTH
--Paul

cigless ...
 
thats because you are incrementing a copy of the counter but not feeding back into the line of the array before printing it to file.

fiddle around with this:

Code:
foreach my $moddata2 (@data2) {
   #chomp $moddata2;#<-- not needed if this all you are doing in this loop.
   my @data = split(/\|/, $moddata2);
   $data[4] += 1 if ($TTITLE eq $data[0]);
   $moddata2 = join('|',@data);       
}

open (INF2, ">$dbdata2") || die qq(Can't open "$dbdata2" for write!\n);    
print INF2 @data2;
close(INF2) || die qq(Can't close "$dbdata2" after write!\n);
 
CHEERS EARS

IM A BRIT IF YOU HADNT NOTICED GOT SOME NICE APPLES AND PEARS IF YOUR INTERESTED

OH BYE THE WAY TA IT WORKED GREAT

AND I MUST BE GETTING BETTER COZ I CAN C WHERE U IS AT AND HOW THE CODE WORKED. THANKS TO ALL OF U'S THAT HELPIN ME OUT.

MADAXE
 
If your script is just increment a digit, like 23, you should use:

($TTITLE == $data[0]);

glad its working [sunshine]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top