Since what you have in the here doc looks suspiciously like XML, the right way to do it would be to leverage one of the XML modules such as XML::Twig or XML::LibXML.
You could also do it with s/// but you would be making a rod for your own back.
It turns out that it wasn't obvious what you wanted to do here after all. :-)
The problem (which you haven't spelled out) is that the here doc interpolates when you set $a so your initial $y is never changed. One solution is not to interpolate but to use a placeholder scalar (which could just be "$y" again) and then eval the here document.
#!/usr/bin/env perl use strict; use warnings; my ($y, $out); $y = 'baby'; my $hd = <<'EOT'; Hello $y! EOT eval "\$out = qq{$hd}"; print $out; $y = 'world'; eval "\$out = qq{$hd}"; print $out;
But that's a bit crude. Far better to use a proper templating system.
In reply to Re: Enlarging scalars
by hippo
in thread Enlarging scalars
by WisDomSeeKer34
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |