Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: RunTime & compile Time Doubt on Perl

by kscaldef (Pilgrim)
on Sep 04, 2006 at 00:50 UTC ( [id://570985]=note: print w/replies, xml ) Need Help??


in reply to RunTime & compile Time Doubt on Perl

I'm not sure if you're any more familiar with Java. As a first step to understanding how Perl works, you can consider that it compiles and runs in a somewhat similar way to Java, except that while Java has two commands, 'javac' and 'java', Perl just has one, 'perl' that compiles and then immediately runs the result.

The complete story is more complicated, since Perl can also compile code on the fly even after the run phase has started (and can run code before the compile phase has completed). This is truly powerful, but difficult to wrap your head around.

  • Comment on Re: RunTime & compile Time Doubt on Perl

Replies are listed 'Best First'.
The complete story is more complicated,
by thoglette (Scribe) on Sep 06, 2006 at 02:34 UTC
    The complete story is more complicated still, as perl is able to dynamically link to "Perl" libraries compiled from other languages, including C and C++.

    But this is an aside. The problem in Perl is that certain operations can only be parsed completely in the run-time context.

    Consider the following, for which C has no analog (buffer overflows notwithstanding).

    my $str = $ARGV[0]; eval("use $str;");
    Now, some theorists will complain bitterly that this must slow your code down, but this is usually the least of your problems. (See Optimising Perl.. for example)

    Thog.

    --
    Dorothy Sayers is still correct.
      "Consider the following, for which C has no analog"

      In that particular case, dlopen does provide an analog. In fact, sufficiently devious use of system() and dlopen() and friends can do what eval does. (Not that I would recommend this.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://570985]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-16 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found