On Wed, Sep 24, 2003 at 03:50:24PM +0100, Simon Wistow said: > This sort of works but can't evaluate variables from other packages.
Which is easily fixed. package Bar; use vars qw($somevar); $somevar = 'stuff with "quotes"'; package Bar::Quux; use vars qw($someothervar); $someothervar = 'nooch'; package main; my $foo = 'blah'; my $RARRR = "fleeg with\nlinebreak"; print evalqq(join "",<DATA>); sub evalqq { my $string = $_[0] || return undef; $string =~ s{(\\*)(\$[a-z]+(::[a-z]+)*)} { "\\" x (length($1) / 2) . (!(length($1) % 2) && do { no strict 'vars'; eval $2 } || $2) }ieg; return $string; } __DATA__ $Bar::somevar $Bar::Quux::someothervar Yo! $foo $RARRR $quirka Blah 'rar' "foobbb" \$foo \\$foo