Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: expanding quoted referenced data
by diotalevi (Canon) on Sep 08, 2006 at 17:56 UTC | |
by nobull (Friar) on Sep 09, 2006 at 10:01 UTC | |
by Anonymous Monk on Sep 08, 2006 at 21:44 UTC | |
Re: expanding quoted referenced data
by shmem (Chancellor) on Sep 08, 2006 at 17:01 UTC | |
Re: expanding quoted referenced data
by philcrow (Priest) on Sep 08, 2006 at 17:02 UTC | |
Re: expanding quoted referenced data
by Anonymous Monk on Sep 08, 2006 at 17:30 UTC | |
by ikegami (Patriarch) on Sep 08, 2006 at 17:43 UTC | |
by shmem (Chancellor) on Sep 08, 2006 at 17:50 UTC | |
by Anonymous Monk on Sep 08, 2006 at 17:39 UTC |