File handling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vindesh
    New Member
    • Jul 2006
    • 6

    File handling

    How to delete a record from the txt file cheking condition is userid && userlogin
    then a i want to delete a perticular line is delete
  • dhascruz
    New Member
    • Aug 2006
    • 3

    #2
    if you want to delete a line from the text. You have to do the below things.

    Ex.
    if the text file has user id as User1 and userlogin as User1. assume the datas in the text files are in tab separated.
    if the test. txt has the value like below
    User1 User1

    open fi, "<test.txt" ;
    while(<fi>)
    {
    $temp1=$_;
    if ($temp1=~m/^(.*?)\t(.*?)\t (.*)/)
    {
    $temp1=~ s/$1$2$3//;
    }
    $temp1=~ s/([\n]+)//g;
    }

    close fi;

    Comment

    Working...