Squirt a small amount of glue on the carpet backing where the carpet was connected.
Push the disconnected loop end into the carpet backing with the darning needle.
Hold the connecting end of the loop for a short time to let the glue dry.
Cut away the area of the carpet containing damage. Cut only down to the bottom of the carpet, leaving the padding intact.
Remove the cut piece. Use it as a stencil to cut a similar shaped piece from a previously unused piece of carpet or from an inconspicuous area of the closet or underneath furniture.
Put an even amount of carpet glue on the back and edges of the non-damaged piece, not enough that it will get on other parts of the carpet.
Fit carefully the new piece into the hole left by the damaged cutout. Try to maintain the pile direction and any color pattern.
Brush the overlapping fibers between the old and new carpet to mask the cuts.
Let the carpet dry for several hours before walking or vacuuming on it.