Re: Filehandles
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 29 Sep 2005 08:59:53 GMT
Guenther Sohler <guenther.sohler@xxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> Hallo,
>
> I am writing a small parser in perl, which should also be able to
> include files.
> if a include statement happens,
> the prg shall put the current FH onto the stack and open a new file with
> the same FH.
>
> How can I do this as filehandles are special in perl ?
You use what is known as a lexical filehandle:
open my $fh, $file;
These are (slightly simplified) lexical variables that contain a reference
to an anonymous filehandle. The filehandle itself is still global.
Also search CPAN for the keyword "include". What comes up looks like
your problem has been dealt with before.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- References:
- Filehandles
- From: Guenther Sohler
- Filehandles
- Prev by Date: Re: Filehandles
- Next by Date: Re: Can explain the MAP function more clearly? Thanks
- Previous by thread: Re: Filehandles
- Next by thread: Re: Filehandles
- Index(es):
Relevant Pages
|
|