in reply to Analysing text files to obtain statistics on their content.

Welcome to the Monastery. You might want to have a look at Writeup Formatting Tips

This is a syntax error:

if ($filename !~ m^/[a-z]{1,7}\.TXT$/i)

I think you meant this:

if ($filename !~ m/^[a-z]{1,7}\.TXT$/i)

At the start, you store your input file's name in $filename, but when you open it, you expect the name to be in $data1.

This is a syntax error:

$my @t = split (/\s+/); #split sentences into "words"

I think you meant:

my @t = split (/\s+/); #split sentences into "words"

You could also have written that as just "my @t = split" because /\s+/ is the default pattern.

Those are the show stoppers. There are a lot of stylistic concerns (indent!) that won't prevent it from working, but I'll stop here.

Update: Oops, I missed this syntax error:

die("File format not valid\n");)

Just delete the trailing paren.

You also have to declare (with my) $filename or $data1 or both.