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

Search results for query: *

  1. daveryan

    Search text file and open record

    I've just about solved the problem. The only problem is it always writes a second text file, any ideas why? Here is the code: #!c:\perl\bin\perl.exe $records = "Data.txt"; if(-e $records) { open(RECORDS, "<Data.txt") or die "Could not open file."; } else { open(RECORDS, ">Data.txt") or die...
  2. daveryan

    Search text file and open record

    I'm a bit hungover at the moment so can't get my head around it. Thanks for all the suggestions, I'll give it another go on Monday when my head is clearer. I'll let you know how it goes. Dave
  3. daveryan

    Search text file and open record

    InDenial...... The reason for the last open and close is for the other data to be entered into the text file, such as name and date of birth, so I'll have to remove the $ref from that one. I see what you mean about using a elsif, but how do I match the exact 4 digit code from the text file to...
  4. daveryan

    Search text file and open record

    I'm working on a script that asks for a 4 digit number. When a number is then typed in, a search is made of an external text file to see if the number already exists. The text file is in this format: 6393,Smith 2473,Jones 3769,Baker 6369,Evans If the number exists, then that record only is to...
  5. daveryan

    Checking for a 4 digit number

    Tried the while loop and it seems to work, thanks for the help, I think you'll be seeing more of me. Sure I tried this yesterday and didn't work, must have missed something. Here's the code: #!c:\perl\bin\perl.exe print("Enter your four digit customer reference number.\n"); $ref=<STDIN>...
  6. daveryan

    Checking for a 4 digit number

    Right, I think I need to put it in a loop not the if statement. Trying that.
  7. daveryan

    Checking for a 4 digit number

    OK, this is now my code, it works the first time but will accept 3 and 5 digit numbers the second time. #!c:\perl\bin\perl.exe print("Enter your four digit customer reference number.\n"); $ref=<STDIN>; if ($ref!~m/^[0-9]{4}$/) { print("Not a valid number, please enter your correct customer...
  8. daveryan

    Checking for a 4 digit number

    Thanks for the replies, I'm not at school, I'm 40 years old, although it is course work. The script does not accept a 3 digit number the first time of asking, it tells me the number is invalid, but it will accept a 3 digit number the second time. I'm guessing I need to put a ^ for the...
  9. daveryan

    Checking for a 4 digit number

    I'm having problems with a perl script I'm working on for some course work. The script asks for a four digit number before going onto the next part of the script. The problem is I need the script to only accept a four digit number but whatever I try I can usually get it to accept three figures...

Part and Inventory Search

Back
Top