> Thanks for the help!! Unfortunetly this solution only copies the modified
> line to the tmp file.  I need the all the other data to stay unchanged.
> e.g.   John:1111111:0
>          Peter:2222222:0
>          Jane:3333333:0
>
> becomes
>
>          John:1111111:0
>          Peter:2222222:1                 #where peter is the name called in
> the input
>          Jane:3333333:0
>
> Thanks anyway!
>
> Patrick Bateman
>

   Are you sure that this is what happened? I tried this on my machine and it
worked
   prac1.txt before running the script
   John:1111111:0
   Peter:2222222:0
   Jane:3333333:0

   After running the script
   prac1.txt.old
   John:1111111:0
   Peter:2222222:0
   Jane:3333333:0

   prac1.txt
   John:1111111:0
   Peter:2222222:1
   Jane:3333333:0

   The script that I used
   #!/usr/bin/perl -w
   use strict;

   open (FIND, "prac1.txt") or die "Error Message";
   open (TMPFIND, ">prac1.txt.tmp") or die "Error Message";

   while (<FIND>) {
      chomp;
      my ($name, $phone, $count) = split (/:/);
      $count++ if ($name eq $ARGV[0]);
      print TMPFIND join (':', $name, $phone, $count), "\n";
   }
   close (FIND);
   close (TMPFIND);
   rename ("prac1.txt", "prac1.txt.old");
   rename ("prac1.txt.tmp", "prac1.txt");

   HTH,
   Sudarsan




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to