From 901d24c23e59de511286986bfd1ff391eaa8b3f2 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 3 Jun 2013 11:43:24 -0500 Subject: the #line stuff means that this doesn't have to be unreadable anymore --- lib/Reply/Plugin/Defaults.pm | 9 ++++++++- lib/Reply/Plugin/Hints.pm | 16 +++++++++++++++- lib/Reply/Plugin/Packages.pm | 10 +++++++++- 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 <{package};\n$line\n;BEGIN { \$" . __PACKAGE__ . "::package = __PACKAGE__ }"; + my $package = __PACKAGE__; + return <{package}; +$line +; +BEGIN { + \$${package}::package = __PACKAGE__; +} +LINE } sub compile { -- cgit v1.2.3-54-g00ecf