On Sat, 2005-03-26 at 00:27 -0800, Larry Wall wrote:

> $$ is now $*PID.  ($$foo is now unambuous.)
> 
> $0 is gone in favor of $*PROGRAM_NAME or some such.

You know, Java did one thing in this respect that I liked, and managed
to do it in a way that I couldn't stand. The idea of program as object
was nice, but they made the programmer manage it, which was really kind
of silly.

If you think of the OS-level shell around a Perl interpreter as an
object, and make perl manage that for you, then this falls out rather
nicely:

        $*PID := $*PROC.pid;
        $*PPID := $*PROC.ppid;
        $*PROGRAM_NAME := ~$*PROC;

Perhaps even some often-used data could be shoved in there:

        $life = time() - $*PROC.start_time;

In fact, it seems like a good place for any OS-level globals:

        $*IN := $*PROC.pio_in // $*PROC.stdin;

If we consider $*PROC to be the invocant of the implicit "main", then:

        say "I am number {.pid}, who is number 1?";

works just fine in global context. This also gives you a nice simple way
to drill down into your interpreter / runtime / VM / whatever state:

        say "I'm {.name} running under {.interp.name}";


Reply via email to