In-lining Perl Code??? 
Author Message
 In-lining Perl Code???

Here's the scenario.  I have a perl program that takes as an argument
the name of a file containing additional perl code.  The additional perl
code is to be executed in two nested loops.

What I would like is the ability for perl just to in-line that code prior
to compilation.  I do not want to do it as a subroutine or eval for
speed purposes.

Many thanks,

david

--
David W. Bourgoyne                      Texas Instruments Dallas, Tx

****************************************************************************
A wise man said: If it didn't come with source, it's firmware not software :)



Tue, 30 Jan 1996 01:24:47 GMT  
 In-lining Perl Code???

:Here's the scenario.  I have a perl program that takes as an argument
:the name of a file containing additional perl code.  The additional perl
:code is to be executed in two nested loops.
:
:What I would like is the ability for perl just to in-line that code prior
:to compilation.  I do not want to do it as a subroutine or eval for
:speed purposes.

Are you sure it would be do slow?

Anyway, you could do this:

    $code = <<'EOF';
# all your code BEFORE your included part goes here
EOF
    $code .= `cat $file_to_include`;
    $code .= <<'EOF';
# all your code AFTER your included part goes here
EOF
    eval $code;

I don't go for the #include method much anymore, but you might
try that instead.

--tom

--



Tue, 30 Jan 1996 04:47:16 GMT  
 In-lining Perl Code???

   Here's the scenario.  I have a perl program that takes as an argument
   the name of a file containing additional perl code.  The additional perl
   code is to be executed in two nested loops.

   What I would like is the ability for perl just to in-line that code prior
   to compilation.  I do not want to do it as a subroutine or eval for
   speed purposes.

If the loops are included in the eval, it shouldn't be much of a performance
hit.  However, you can do the inlining courtesy of the -P option, which
runs the script through the C preprocessor, except that it can't include
an argument because the arguments aren't known until after compilation!
It seems to me that the overhead in working around that would be greater than
(and less elegant than) using the eval.

--

"When the only tool you have is Perl, the whole | "Hooray for snakes!"
 world begins to look like your oyster." -- Me  |  -- The Simpsons (29 Apr 93)



Tue, 30 Jan 1996 23:18:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Inlining images with Perl on Windows NT ?

2. HELP: Automatic Execution of perl scripts RE: first line of code #!/usr/bin/perl/

3. inlining a pattern

4. Inlining Modules

5. Inlining "require" files

6. Inlining object methods via preprocessor for efficiency (!?)

7. inlining your sort subroutine

8. Inlining GD.pm??

9. Perl module to count lines of code and comments

10. Perl script for counting lines of c code

11. end-of-line characters for distributed Perl code

12. Where to post Perl code (<100 lines)

 

 
Powered by phpBB® Forum Software