>At 20.08 -0400 1999.04.09, jason white wrote: >>Pretty low level question here... >>Any one got a good pointer on how to convert Carriage returns/linefeeds >>etc. I just need to be able to capture them and then I'll convert them >>into <br> tags . Basically I want it to take the cr , lf, or crlf and make >>it like the user put it in (if they put a hard return). I know the ascii >>values are 10 and 13. I've done this with other scripting languages >>(ToolBook, HyperCard etc.) but not in Perl yet. Is it just a matter of >>converting Hex values? > >Well, it depends. The basic answer is: > > $text =~ s/\015/\012/g; # i like octals :) > $text =~ s/\x0D/\x0A/g; # same thing > >But really, if you need more than that, I would need to know exactly what >you want to do, like: > >* change CR to LF >* change CR or CRLF to LF >* change LF or CRLF to CR >* change any of CR, LF, or CRLF to local newline > >etc. I imagine you might want the latter, and it gets to be more >difficult, because first you have to identify what the newline characters >are. I would do something like: > > my($nl) = ($text =~ /(\015?\012|\015)$/); # get which newline used > $text =~ s/$nl/\n/g; # change all "newlines" to local newline, \n > >-- basically, I want to turn any new line...(CR for Mac, CRLF for PC, LF for UNIX/LINUX) and turn it into a <br> tag in my parsing. The simple s/\n\r/<br>\n/g; seems to work. Tried it on both PC and Mac. Don't have a Unix Box to check it at the moment, but would assume it would work equally as well. I want to venture into the octal/hex world but have only tinkered. I like to at lest semi-understand it if I code it, and I don't even have time for that partial understanding at the moment. Thanks for all the help. Jason ------------------- Jason White <Insert Title Here> jason.white@usu.edu ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org