in reply to What?? delete chars.

use strict; use strict; use strict;

Your 'my $data' declares the $data variable within the while loop. When you exit that loop, the variable will cease to exist.