CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
do, but as if with -x ?


New User

Jul 9, 2013, 11:59 AM

Post #1 of 3 (14598 views)
do, but as if with -x ? Can't Post

Hello all

Expecting the answer no, but is there any built-in way to 'do' a Perl source file in the way that the -x switch would (discard leading garbage etc etc)?



Jul 9, 2013, 3:01 PM

Post #2 of 3 (14593 views)
Re: [dugeen] do, but as if with -x ? [In reply to] Can't Post

Let me make sure that I understand you correctly. You have two files. The first is a normal perl program. The second has perl code embedded in something else. You want the first program to execute the perl code in the second. You can execute that code from the command line by using perl -x secondfile.

Good question. I agree that there probably is not an easy way to do it. You could read the second file into a string and execute the string. Use the flip/flop operator (..) to store only the lines from the #! to the __END__.
Good Luck,

New User

Jul 10, 2013, 2:20 PM

Post #3 of 3 (14583 views)
Re: [BillKSmith] do, but as if with -x ? [In reply to] Can't Post

Yep, you've understood me perfectly.

It's as I thought, then - I have to parse the Perl code out from the second file myself, and 'eval' or 'do' it when I've got it.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives