John Nurick wrote:
> On 7 Jan 2006 02:04:36 -0800, "Brian McCauley" <>
> wrote:
>
> >Newsgroup Reader wrote:
> >> Hi: Does anyone know how to read a perl script from within itself?
>
> >You can abuse the DATA handle.
>
> [snip]
>
> > seek(DATA,0,0);
>
> Please excuse my ignorance, but why is this preferable to
>
> open $theScript, "<", $0
$0 is not reliably a full path name that can be used to find the script
file.
A more relable path name can be found using the FindBin module. But
even that's not 100% relialble (for details "perldoc FindBin").
Besides, even if it were 100%, why reopen the file?
|