in reply to Re: Re: Double slashes in regex causing problems
in thread Double slashes in regex causing problems
However, I've confirmed that (on my 5.6.0 ActiveState build) the deep hash value is not being modified when bound as the lvalue against a s/// operator containing slashes, but it works with a trivial pattern and replacement.
Update: Duh, a typo. This is working fine for me.
This sort of pattern is common in blogs and stuff, to find and linkify things that look like URLs. However, you need to be careful about trailing characters that the user has typed as a part of their blog entry. For example, see here (http://perlmonks.org) for a DNS error or here (http://perlmonks.org/index.pl) for a 404 error because of the closing parenthesis characters.use strict; use warnings; use Data::Dumper; my $msg = 'a'; my $mhash; $$mhash{entries}{$msg}{text} = "This is a http://foo/bar.html test."; $$mhash{entries}{$msg}{text} =~ s!http://(\S+)![<a href="http://$1" >f +oo</a>]!g; print Dumper $mhash; __OUTPUT__ $VAR1 = { 'entries' => { 'a' => { 'text' => 'This is a [<a href="http://foo/ +bar.html" >foo</a>] test.' } } };
--
[ e d @ h a l l e y . c c ]
|
|---|