my $text = "foo\nbar\nbaz\n"; my $lb = () = $text =~ /(\n)/g; print "$lb\n";