I do love the feeling of fixing a ton of user requesst/defects. It certainly makes the day go by.
Although one fix felt a bit like voodoo.
I'm pulling some text out of mysql so the newlines are escaped. This string looks like:
$description = 'piece of text\r\nsome more text'
My hack is to do the following:
$description =~ s/^'//;
$description =~ s/'$//;
$description =~ s/\\(['"])/$1/gso;
$description =~ s/&/&/gso;
$description =~ s/</gso;
$description =~ s/>/>/gso;
$description =~ s/"/"/gso;
$description =~ s/'/'/gso;
$description =~ s/\\r\\n/\n/gso;
$description = Text::Autoformat::autoformat
$description,
{right => 50,
fill => 0,
squeeze => 0,
all => 1,
};
$description = pre( $description );
I was using escapeHTML() but that seemed to gobble some of the newlines.
I suppose I really should be posting this on ciwac instead of my journal...
Re:regexps
gizmo_mathboy on 2002-06-07T00:36:09
Nice ideas. I'll have to integrate them into my code. To be truthful I lifted most of them from escapteHTML from CGI.pm.
escapeHTML seemed to be chewing up some newlines so I lifted the bits that escaped the entities I wanted.
I really should put this one up on perlmonks and/or ciwac.