You don't want to "initialize" to undef. All scalars start out as 'undef', so this is precisely what perl is looking for when emitting this warning. If you want to initialize a variable, initialize it to something that makes sense for your application. In this case, @data is being printed out as a string, so an empty string might be appropriate.
$ perl -we 'print undef'
Use of uninitialized value in print at -e line 1.