フツーに

my $len = split /\n/, $source;

で行数が取れると思うんだが…?
試してみたけど

> Use of implicit split to @_ is deprecated at ./a

なんて出なかったよ?