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

Coding Error with FIles

Status
Not open for further replies.

pdhharris

Programmer
Joined
May 20, 2008
Messages
1
Location
US
Hello everyone. I am having an issue with the following code snippet. It works fine if I comment out the ordern file part... I am wondering if there is an issue having two files open?

Thanks!

Code:
if (uc($INPUT{step}) eq uc("two"))
 {
  #Get Order Num - This section is where the error is
  open (ORDERN, "+<OrderNum.dat") or die $!;
   $INPUT{order_num} = <ORDERN>;
   $new = $INPUT{order_num}+1;
   print ORDERN $new;
  close(ORDERN); 
 #Submit Order
  open(FILEH, ">>Order.dat") or &dienice("Can't open Order.dat for writing: $!");
  while ( my ($key, $value) = each(%INPUT) ) 
   {
        print FILEH "$key:$value,";
   }
  print FILEH "\n";
  close(FILEH);
  print "Done!";
 }
 
Opening two files should not be a problem. Are you getting any errors or is "die" returning anything when you try and open the file? Try dropping the '+<' and see if that helps.

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

Part and Inventory Search

Sponsor

Back
Top