in reply to Re: Search and substitute into data structures
in thread Search and substitute into data structures

Thanks! And what about wrap_cdata, to wrap the content with <![CDATA ]> in the approach of your trick ?
  • Comment on Re^2: Search and substitute into data structures

Replies are listed 'Best First'.
Re^3: Search and substitute into data structures
by Sidhekin (Priest) on Apr 30, 2007 at 19:47 UTC

    Thanks! And what about wrap_cdata, to wrap the content with [I assume] <![CDATA[ ]]> in the approach of your trick ?

    Same thing, as long as you know how to do it with a single string. Perhaps something like this:

    sub wrap_cdata { for (@_) { eval { wrap_cdata(@$_); 1 } and next; eval { wrap_cdata(values %$_); 1 } and next; s/(?<![^>])([^<]+)/<![CDATA[$1]]>/g; } }

    Or not. I don't know why your original unwrap did not use the /g modifier. So please, season to taste.

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!