in reply to Better heredocs?
But then I looked at Jenda's offering, and decided to marry the two approaches:sub get_content { my $n = shift; my $content = qq( <html> <foo> <bar>blah</bar> </foo> </html>); $content=~s{(?:^[\n\r]\s{4}|[\n\r]+\s{4})(.*)}{$1\n}gm; return $content; }
Works great! Keep polishing that rice bowl.sub get_content { my $n = shift; my $content = qq( <html> <foo> <bar>blah</bar> </foo> </html>); unIndent($content); return $content; } sub unIndent { $_[0] =~ s/^[\n\r]*//; my ($indent) = ($_[0] =~ /^([ \t]+)/); $_[0] =~ s/^$indent//gm; }
|
|---|