This replaces the comma lines with the value of null, not the string. If you want the string, just put 'null' in the right side. The way you were approaching the pattern match, the '^' and '$' pinned the match to the beginning and end of the file...... not the beginning and end of a line. So, just treat the '\n' as any other character and match it. Like this,
#!/usr/local/bin/perl
$lines = `cat junk.txt`;
$lines =~ s/\s*?,\s*?\n//g;
print "lines - $lines";
Where junk.txt looks like,
,
,
,
some, text,
,
HTH
keep the rudder amid ship and beware the odd typo