Hi skip

> Sorry to ask a Perl question here, but...  Does Perl have something like
> Python's repr() function?  I want to print out a string and have CR print as
> \r, LF as \n, etc.  I looked in the Perl/Python phrasebook:

Have a look at this:

# -------- cmp_rep.pl ----------- #
#!/usr/bin/perl -w
use String::Escape qw(printable);

# - - - - the perl way - - - - -
$st = "str\ting\n";
print "In Perl:\n", printable($st);

# - - - - the python way - - - -
use Inline Python => <<'PYEND';
st="str\ting\n";
print "\nIn Python:\n", repr(st)
PYEND
# ------------------------------- #

Should give "almost" the same results

Regards

Mirco
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to