"David K. Wall" <> wrote:
> If I want a program to print its own source code, is there any reason
> to prefer one of these code snippets over the other? Or is there an
> even better way to do it?
>
> Snippet 1:
>
> seek DATA, 0, 0;
> print <DATA>;
> __DATA__
>
>
> Snippet 2:
>
> open SELF, $0 or die "Error opening self for reading";
> print <SELF>;
I would prefer the first, just because I always prefer to use a handle
I've got on the file rather than open another... also, I believe $0 is
not always perfectly reliable, as in there are some situations on some
OSen where it is impossible for perl to correctly find the path to the
running script.
In any case, the second should use FindBin (modulo the thread a while
ago about whether or not it's broken...).
Ben
--
EAT
KIDS (...er, whoops...)
FOR
99p