in reply to DATA versus config file

muntfish and Solo both make excellent points. To add to what Solo said re: daemonizing your script. It is important to note that once the DATA handle is read, it cannot (easily) be re-read (seeking to the beginging of the file puts you at the top of your source, not the top of the DATA handle). So if you were to convert it to a daemon, you would need to watch out for this. But then if you daemonize it, you would be better off with an external config anyway, that way it your config can change without restarting your daemon.

-stvn

Replies are listed 'Best First'.
Re: Re: DATA versus config file
by Fletch (Bishop) on May 18, 2004 at 15:02 UTC
    It is important to note that once the DATA handle is read, it cannot (easily) be re-read (seeking to the beginging of the file puts you at the top of your source, not the top of the DATA handle).

    Erm, no it's very easy to do this.

    #!/usr/bin/perl use Fcntl qw( :seek ); my $top_o_data = tell( DATA ); for( 1 .. 2 ) { print "read $_\n---\n"; seek( DATA, $top_o_data, SEEK_SET ); print while <DATA>; } __DATA__ Wubba. Zoikes. Jinkies.

    Update: The problem of course is that you may not see updates (at least not on OS X or Linux that I've checked).