in reply to Using data at the end of a program file

I'm not sure what POE::Component::Logger wants, but I suspect that it's a configuration file on it's own; in that case, it's a bit difficult just to point it at the calling script, since I don't think you can easily tell it to "open this file, but only start from after '__END__'".

However, you could create a temporary file from a "here" document:

open TEMPFILE, ">$temp_filename"; print << END_OF_HEREFILE .... ... write your config file stuff here .... ... END_OF_HEREFILE close TEMPFILE; POE::Component::Logger->spawn(ConfigFile => $temp_filename); ... unlink ($temp_filename);
Remember you need to add in the unlink somewhere to delete the tempfile; you need to decide where it should go depending on your code.

Replies are listed 'Best First'.
Re^2: Using data at the end of a program file
by carcassonne (Pilgrim) on Feb 21, 2006 at 14:46 UTC
    Thanks, that's just about the right solution, apart from one little thing. But first, a correction:

    print << END_OF_HEREFILE

    should be (if not, the Perl I'm using will say it's deprecated) :

    print TEMPFILE <<END_OF_HEREFILE;

    And then, this approach, as it is, will have the print statement print out the following warning at the console:

    /tmp/log1.conf: No such file or directory

    Up to now I cannot get rid of these messages. Creating a file beforehand like this does not help:

    open(LOG1, ">/tmp/log1.conf"); print LOG1 "test"; close LOG1;

    I think it's because the file does not get actually created on the disk. Not flushed or something. Because if files are simply 'touched' at the console before running the code, the print warnings are not displayed.

    There must be a Perl way of doing this ! ;-)