yoda54 has asked for the wisdom of the Perl Monks concerning the following question:
I keep getting "readline() on unopened filehandle DATA at (eval 1) line 5." when evaling a script with a __DATA__ section. Would you have any pointers to fix?
Thanks!
#!/usr/bin/perl use strict; use warnings; open(F, "test.pl"); my $f = do { local $/; <F> }; close(F); eval ($f); Test.pl: #!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; print "TEST: *$_*\n"; } close DATA; __DATA__ TEST 1 2 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Losing __DATA__ when evaling script.
by Loops (Curate) on Jun 19, 2013 at 01:36 UTC | |
| |
|
Re: Losing __DATA__ when evaling script.
by LanX (Saint) on Jun 19, 2013 at 01:36 UTC | |
|
Re: Losing __DATA__ when evaling script.
by tobyink (Canon) on Jun 19, 2013 at 07:35 UTC | |
|
Re: Losing __DATA__ when evaling script.
by tobyink (Canon) on Jun 19, 2013 at 08:45 UTC |