Subject: | dos files and \r\n |
Version 1.07
Using a linux system, with files created on a windows system (\r\n end of line markers) fails to strip </%args> and (and other block closing tags) out of the code.
(the same files run flawlessly in Mason itself)
The attached patch should correct this behaviour.
BTW, thanks for an excellent module
--- /usr/local/share/perl/5.8.4/Text/MicroMason.pm 2003-09-26 18:26:59.000000000 -0400
+++ MicroMason.pm 2004-11-24 17:03:13.000000000 -0500
@@ -81,19 +81,19 @@
$_
} elsif ( s/\A\<\%perl\>// ) {
# Blocks in <%perl> ... <%perl> tags.
- s/\<\/\%perl\>\Z// and $_
+ s/\<\/\%perl\>(?:\r\n|\Z)// and $_
} elsif ( s/\A\<\%init\>// ) {
# Blocks in <%init> ... <%init> tags get moved up to start of sub
- s/\<\/\%init\>\Z// and unshift(@code, "$_;") and ()
+ s/\<\/\%init\>(?:\r\n|\Z)// and unshift(@code, "$_;") and ()
} elsif ( s/\A\<\%cleanup\>// ) {
# Blocks in <%cleanup> ... <%cleanup> tags get moved down to end of sub
- s/\<\/\%cleanup\>\Z// and unshift(@post, "$_;") and ()
+ s/\<\/\%cleanup\>(?:\r\n|\Z)// and unshift(@post, "$_;") and ()
} elsif ( s/\A\<\%once\>// ) {
# Blocks in <%once> ... <%once> tags get moved up above the sub
- s/\<\/\%once\>\Z// and unshift(@pre, "$_;") and ()
+ s/\<\/\%once\>(?:\r\n|\Z)// and unshift(@pre, "$_;") and ()
} elsif ( s/\A\<\%args\>// ) {
# Blocks in <%args> ... <%args> tags.
- s/\<\/\%args\>\Z//;
+ s/\<\/\%args\>(?:\r\n|\Z)//;
s/^\s*([\$\@\%])(\w+) (?:\s* => \s* ([^\r\n]+))?/
"my $1$2 = exists \$ARGS{$2} ? " .
( ($1 eq '$') ? "\$ARGS{$2}" : "$1\{ \$ARGS{$2} }" ) . " : " .