in reply to expanding quoted referenced data

Missing the point. The regex has to catch $lamb->{data}[0].

Catching $lamb is an easy cut 'n paste job. Getting it to catch $lamb->{data}[0] whether or not there is a space or period after, and not losing the referenceness of the reference is the issue.

Replies are listed 'Best First'.
Re^2: expanding quoted referenced data
by ikegami (Patriarch) on Sep 08, 2006 at 17:43 UTC
    my $lamb; $lamb->{data}[0] = 'wolf'; my $mary = "Little Rabbit Foo Foo"; my $template = '$mary had a little $lamb->{data}[0].'; $text = eval qq{"$template"}; print $text;

    You're treading down a dangerous path. Why don't you use an existing template system instead of rolling out your own?

Re^2: expanding quoted referenced data
by shmem (Chancellor) on Sep 08, 2006 at 17:50 UTC
    Ah, ok. Then -
    my $lamb; my $mary="Little Rabbit Foo Foo "; $lamb->{data}[0] = 'wolf'; my $text = '$mary had a little $lamb->{data}[0].'; $text =~ s/(.*)/"\"$1\""/ee; print $text,"\n"; __END__ Little Rabbit Foo Foo had a little wolf.

    but then, there's an extra space between "Foo Foo" and "had", since $mary's got it. Maybe $mary =~s/^\s|\s$/g, then.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re^2: expanding quoted referenced data
by Anonymous Monk on Sep 08, 2006 at 17:39 UTC
    My bad.

    I keyed on the simpler regex you quoted and didn't try it without the space/period alternates. Thanks for the help.