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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

umm need help again.

Status
Not open for further replies.

TmlMatus

Technical User
Nov 24, 2007
12
CA
this is my current code

-----------------------------------------

#!/usr/bin/perl

use CGI qw:)standard);


print "Content-type: text/html\n\n";

$HTML = "message.htm";
open (HTML) or die "Can't open the file!";
print <HTML>;
close (HTML);

my $file = "productselection.txt";


open( LOG, "$file" ) or die "Cannot open file $!";
my $cnt = <LOG>;
close(LOG);

++$cnt;

open( LOG, "> $file" ) or die "Cannot open file $!";
print LOG $cnt;
close(LOG);

---------------------------------------
The counter goes work fine. But i want to add this code in also so go beside the counter number.

---------------------------------------
open(FILE,">productselection.txt");
flock(FILE,$exclusive_lock);

print FILE param("Input10");
print FILE param("Input11");
print FILE param("Input12");
print FILE param("Input13");

flock(FILE,$unlock_lock);
close(FILE);

----------------------------------------
now everytime i add this code ... instead of the input # going beside the counter ... they overwrite the counter.

i tried using arrays but i just couldnt get it to work.

... please help ... kinda urgent.
 
This line [tt]open(FILE,">productselection.txt");[/tt] should be [tt]open(FILE,">>productselection.txt");[/tt].
Your code is quite obscure though: every time it is executed, you destroy the [tt].txt[/tt] file to overwrite with the number of lines that were in +1, locking is not always used, the variable [tt]$file[/tt] is used occasionally...
Also there is no newline character after the counter, [tt]Input10[/tt] will be on its same line.

Franco
: Online tools for structural design
: Magnetic brakes for fun rides
: Air bearing pads
 
very obscure, does this even work?


Code:
open (HTML) or die "Can't open the file!";


there is no filename to open! Maybe he means to do this:


Code:
open (HTML, $HTML) or die "Can't open the file!";


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top