increment line for each eval
[p5sagit/Eval-WithLexicals.git] / lib / Eval / WithLexicals.pm
index 752de55..8faa583 100644 (file)
@@ -4,7 +4,7 @@ use Moo;
 use Moo::Role ();
 use Sub::Quote;
 
-our $VERSION = '1.001000'; # 1.1.0
+our $VERSION = '1.002000'; # 1.2.0
 $VERSION = eval $VERSION;
 
 has lexicals => (is => 'rw', default => quote_sub q{ {} });
@@ -17,7 +17,7 @@ has lexicals => (is => 'rw', default => quote_sub q{ {} });
     isa => sub {
       my ($val) = @_;
       die "Invalid context type $val - should be list, scalar or void"
-       unless $valid_contexts{$val};
+        unless $valid_contexts{$val};
     },
   );
 }
@@ -30,6 +30,8 @@ has prelude => (
   is => 'rw', default => quote_sub q{ 'use strictures 1;' }
 );
 
+has line => ( is => 'rw', default => 1 );
+
 sub with_plugins {
   my($class, @names) = @_;
 
@@ -53,6 +55,8 @@ sub eval {
   local *Eval::WithLexicals::Cage::grab_captures;
 
   my $package = $self->in_package;
+  my $line = $self->line;
+  $self->line($line+1);
   my $setup_code = join '', $self->setup_code,
     # $_[2] being what is passed to _eval_do below
     Sub::Quote::capture_unroll('$_[2]', $self->lexicals, 2);
@@ -63,7 +67,7 @@ sub eval {
 ${setup_code}
 sub Eval::WithLexicals::Cage::current_line {
 package ${package};
-#line 1 "(eval)"
+#line $line "(eval)"
 ${to_eval}
 ;sub Eval::WithLexicals::Cage::pad_capture { }
 ${capture_code}
@@ -137,6 +141,9 @@ sub _eval_do {
   }
 }
 
+1;
+__END__
+
 =head1 NAME
 
 Eval::WithLexicals - pure perl eval with persistent lexical variables
@@ -259,6 +266,8 @@ Matt S. Trout <mst@shadowcat.co.uk>
 
 David Leadbeater <dgl@dgl.cx>
 
+haarg - Graham Knop (cpan:HAARG) <haarg@cpan.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2010 the Eval::WithLexicals L</AUTHOR> and L</CONTRIBUTORS>
@@ -270,5 +279,3 @@ This library is free software and may be distributed under the same terms
 as perl itself.
 
 =cut
-
-1;