[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] Converting CR's LF's etc.



>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?
>
>Thanks,
>
>Jason

You can use the substitution operator.
I think something like the following should work:

$line =~ s/[\n\r]/<br>\n/g;

-Chris

  /'\   Chris Seidel
  \_/   Dept of MCB UC Berkeley
   #    http://www.he.net/~seidel/
 /\#/\  PhageT4 on the Pedestal (Corner of Berkeley & Oxford '96 -'99)



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org