Mailing List Archive

svn commit: r1556241 - /perl/embperl/trunk/Embperl/Inline.pm
Author: richter
Date: Tue Jan 7 15:20:02 2014
New Revision: 1556241

URL: http://svn.apache.org/r1556241
Log:
Embperl::Inline: Fix line numbering, allow to set options for compile of Embperl content

Modified:
perl/embperl/trunk/Embperl/Inline.pm

Modified: perl/embperl/trunk/Embperl/Inline.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Inline.pm?rev=1556241&r1=1556240&r2=1556241&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Inline.pm (original)
+++ perl/embperl/trunk/Embperl/Inline.pm Tue Jan 7 15:20:02 2014
@@ -18,6 +18,21 @@

package Embperl::Inline ;

+use strict ;
+use vars qw{$options} ;
+
+sub import
+ {
+ if (ref $_[1] eq 'HASH')
+ {
+ $options = $_[1] ;
+ }
+ else
+ {
+ $options = undef ;
+ }
+ }
+
sub compile

{
@@ -29,7 +44,7 @@ sub compile
#$debug = $Embperl::req -> config -> debug ;
}

- #print STDERR "compile: $file, code = $code\n" ;
+ #print STDERR "compile: $file, code = $code, options = $options\n" ;

Embperl::Execute ({ 'inputfile' => $file,
'input' => $code,
@@ -38,6 +53,7 @@ sub compile
'firstline' => $line,
'package' => $package,
#'debug' => $debug,
+ ($options?(%$options):()),
'use_env' => 1}) ;
}

@@ -47,7 +63,7 @@ use Embperl ;

FILTER
{
- s/\n__EMBPERL__(.+)$/\nBEGIN { my \$line = __LINE__ - 2 ; my \$code = q{$1}; Embperl::Inline::compile (\\\$code, \$line, __FILE__, __PACKAGE__)}/s ;
+ s/\n__EMBPERL__(.+)$/\nBEGIN { my \$line = __LINE__ - 1 ; my \$code = q{$1}; Embperl::Inline::compile (\\\$code, \$line, __FILE__, __PACKAGE__)}/s ;
} ;


@@ -91,6 +107,10 @@ The only thing that needs to be done for
use Embperl::Inline and to place your Embperl code after
the C<__EMBPERL__> keyword.

+After the use Embperl::Inline it is possible to specify Embperl parameters e.g.:
+
+ use Embperl::Inline { options => &Embperl::Constant::optKeepSpaces };
+
=head1 Author

G. Richter (richter at embperl dot org)



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org