summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-03 11:43:24 -0500
committerJesse Luehrs <doy@tozt.net>2013-06-03 11:43:24 -0500
commit901d24c23e59de511286986bfd1ff391eaa8b3f2 (patch)
treeea3e3bc1c60d98f307550d10ce1b1409aba547f5
parent95d6cfd3679870b6d265640b23e7537d657458ea (diff)
downloadreply-901d24c23e59de511286986bfd1ff391eaa8b3f2.tar.gz
reply-901d24c23e59de511286986bfd1ff391eaa8b3f2.zip
the #line stuff means that this doesn't have to be unreadable anymore
-rw-r--r--lib/Reply/Plugin/Defaults.pm9
-rw-r--r--lib/Reply/Plugin/Hints.pm16
-rw-r--r--lib/Reply/Plugin/Packages.pm10
3 files changed, 32 insertions, 3 deletions
diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm
index 0296c70..b0c4e88 100644
--- a/lib/Reply/Plugin/Defaults.pm
+++ b/lib/Reply/Plugin/Defaults.pm
@@ -25,7 +25,14 @@ sub read_line {
return scalar <>;
}
-my $PREFIX = "package main; BEGIN { \$^H = \$" . __PACKAGE__ . "::default_hints; \%^H = \%\$" . __PACKAGE__ . "::default_hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::default_warning_bits }";
+(my $PREFIX = <<'PREFIX') =~ s/__PACKAGE__/__PACKAGE__/ge;
+package main;
+BEGIN {
+ $^H = $__PACKAGE__::default_hints;
+ %^H = %$__PACKAGE__::default_hinthash;
+ ${^WARNING_BITS} = $__PACKAGE__::default_warning_bits;
+}
+PREFIX
sub compile {
my $self = shift;
diff --git a/lib/Reply/Plugin/Hints.pm b/lib/Reply/Plugin/Hints.pm
index af557e3..ac31ceb 100644
--- a/lib/Reply/Plugin/Hints.pm
+++ b/lib/Reply/Plugin/Hints.pm
@@ -29,7 +29,21 @@ sub mangle_line {
my $self = shift;
my ($line) = @_;
- return "BEGIN { \$^H = \$" . __PACKAGE__ . "::hints; \%^H = \%\$" . __PACKAGE__ . "::hinthash; \${^WARNING_BITS} = \$" . __PACKAGE__ . "::warning_bits }\n$line\n;BEGIN { \$" . __PACKAGE__ . "::hints = \$^H; \$" . __PACKAGE__ . "::hinthash = \\\%^H; \$" . __PACKAGE__ . "::warning_bits = \${^WARNING_BITS} }";
+ my $package = __PACKAGE__;
+ return <<LINE;
+BEGIN {
+ \$^H = \$${package}::hints;
+ \%^H = \%\$${package}::hinthash;
+ \${^WARNING_BITS} = \$${package}::warning_bits;
+}
+$line
+;
+BEGIN {
+ \$${package}::hints = \$^H;
+ \$${package}::hinthash = \\\%^H;
+ \$${package}::warning_bits = \${^WARNING_BITS};
+}
+LINE
}
sub compile {
diff --git a/lib/Reply/Plugin/Packages.pm b/lib/Reply/Plugin/Packages.pm
index 8e1b85b..fd48737 100644
--- a/lib/Reply/Plugin/Packages.pm
+++ b/lib/Reply/Plugin/Packages.pm
@@ -18,7 +18,15 @@ sub mangle_line {
my $self = shift;
my ($line) = @_;
- return "package $self->{package};\n$line\n;BEGIN { \$" . __PACKAGE__ . "::package = __PACKAGE__ }";
+ my $package = __PACKAGE__;
+ return <<LINE;
+package $self->{package};
+$line
+;
+BEGIN {
+ \$${package}::package = __PACKAGE__;
+}
+LINE
}
sub compile {