I store data using XML::Simple. I use forcearray so that everything is consistent, and refer to my data as referenced variables. I want to embed a reference in the xml, extract it, and populate it at run time. The variable has to be stored within the string, so it won't get set when the xml file is written.
The usual method doesn't work --
====usual variable substitution idiom for comparison==== my $lamb = 'wolf'; my $text = 'Mary had a little $lamb.'; $text =~ s/(\$\w+) /$1/eeg; print $text;
The solution -- the regex needs an update:
my $lamb; my $mary="Little Rabbit Foo Foo "; $lamb->{data}[0] = 'wolf'; my $text = '$mary had a little $lamb->{data}[0].'; $text =~ s/(\$[\w\-\>\{\}\[\]]+)[ \.]/$1/eeg; print $text;
Is there a cleaner way of writing the regex that doesn't involve extensive tweaking of the data? I'm chafing under the restriction of losing my space or period and having to supply it elsewhere.
In reply to expanding quoted referenced data by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |