JupiterHost.Net wrote:
perldoc B::ByteCode

has an example:
 $ perl -MO=Bytecode,-H,-ohi -e 'print "hi!\n"'
 $ perl hi
 hi!


hi is: #! perl use ByteLoader 0.05; [bytecode]

In the interest of learning a bit I have a couple questions I couldn't seem to find:


1) Is there a way to have code before the use BytLoader.. withotu error, like this:


 #! perl

 my $foo = 'bar;
 print $foo;

 use ByteLoader 0.05;
 [bytecode]

$perl hi
barhi!
$

2) Is there a way to allow the perl in the bytecode to use variabels and functions in the plain text perl code befroe use BytLoader?

For instance is you'd bytecoded a "print "$foo\n";:

 #! perl

 my $foo = 'bar;

 use ByteLoader 0.05;
 [bytecode]

$ perl hi
bar
$

I was hoping for this to print 123:

 $ perl -MO=Bytecode,-H,-ofoob -e 'print "Foo: $foo\n"'
 -e syntax OK
 $ perl -e '$foo = 123;do foob;'
 Foo:
 $

but it didn't work :(

While this does:

 $ cat regp
 #!/usr/bin/perl

 print "Foo: $foo\n";
 $ perl -e '$foo = 123;do regp;'
 Foo: 123
 $

I bet there's a way to do this but I'm a total ByteCode rookie :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to