package and do
esskar
created: 2006-02-02 19:38:14
my $foo = do { package Foo; local $/; ; };
works, reads the __DATA__ section in Foo and writes it to $foo
my $class = 'Bar';
my $bar = do { eval "package $bar"; local $/; ; };
does not work - probably because eval "package $bar" has its own scope.
Any ideas how i can solve my problem?
Re: package and do
created: 2006-02-02 19:59:10
#!/usr/bin/perl

use strict;
use warnings;

my $class = 'Foo';
my $foo = do{ eval "package $class; local \$/; "};
print $foo;

package Foo;

__DATA__
Dies
ist
ein
Test
Re: package and do
created: 2006-02-02 23:52:01
The following works:
my $foo = do { local $/; ; };

wait, that doesn't help you. updating...

perlmonks.org content © perlmonks.org and esskar, ikegami, reneeb

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03