in reply to Re: file contents as a part of code?
in thread file contents as a part of code?

I think that OP want's the contents of the file eval'd .. so, to OP, i would say start with something live the above and simply perldoc -f eval it. Be aware, however, that this can be very dangerous--for example if someone puts malevalent perl code in the file it _will_ get executed.
open FILEHANDLE, '<', '/tmp/MY_DATA' or die $!; my $str = do { local $/; <FILEHANDLE> }; close FILEHANDLE; gnuplot({ "title" => "My Trend", "output type" => "png", "output file" => "$TMPDIR/trend-$$.png"}, eval($str), );
(Note: For slurp explaination, see Perl Idioms Explained - my $string = do { local $/; <FILEHANDLE> };)

Replies are listed 'Best First'.
Re^3: file contents as a part of code?
by halley (Prior) on Aug 17, 2005 at 13:55 UTC
    You teach one 'do' idiom, but then you skip the other power of 'do' and go the long way around.
    die if not -f '/tmp/MY_DATA'; gnuplot({ "title" => "My Trend", "output type" => "png", "output file" => "$TMPDIR/trend-$$.png"}, do '/tmp/MY_DATA' );
    (Not that this is an endorsement of either approach.)

    --
    [ e d @ h a l l e y . c c ]

      This worked like a charm! You guys are geniuses! Thanks for all your suggestions, you guys may have saved the few hairs on my head that I have not pulled out yet ;) Thanks again!!! Dave