What is abriviation for CHR(4)

M

max

Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)

Thanks

Max
 
J

John W. Krahn

max said:
Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)

"\t" could also be represented as "\011" or "\x09" or "\cI" so chr( 4 ) could
be represented as "\04" or "\x04" or "\cD".



John
 
M

max

Thanks
Super is easier that I think.

Max

John W. Krahn said:
"\t" could also be represented as "\011" or "\x09" or "\cI" so chr( 4 ) could
be represented as "\04" or "\x04" or "\cD".



John
 
X

xhoster

max said:
Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)


$ perl -le 'use Data::Dumper; $Data::Dumper::Useqq=1; \
print Dumper [chr(4), chr(9)];'
$VAR1 = [
"\4",
"\t"
];


It looks like "\4" is a good abbreviation, but I imagine it wouldn't
work if followed by a digit (in which case Dumper uses "\004" instead).



Xho
 
B

Ben Morrow

Quoth (e-mail address removed):
max said:
Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)


$ perl -le 'use Data::Dumper; $Data::Dumper::Useqq=1; \
print Dumper [chr(4), chr(9)];'
$VAR1 = [
"\4",
"\t"
];


It looks like "\4" is a good abbreviation, but I imagine it wouldn't
work if followed by a digit (in which case Dumper uses "\004" instead).

"\4" is unreliable under some circumstances: notably, in a pattern (or
the RHS of s///), if $4 exists then \4 is assumed to refer to that
rather than chr(4). "\04" is safer.

Ben
 
X

xhoster

Ben Morrow said:
Quoth (e-mail address removed):
max said:
Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)


$ perl -le 'use Data::Dumper; $Data::Dumper::Useqq=1; \
print Dumper [chr(4), chr(9)];'
$VAR1 = [
"\4",
"\t"
];


It looks like "\4" is a good abbreviation, but I imagine it wouldn't
work if followed by a digit (in which case Dumper uses "\004" instead).

"\4" is unreliable under some circumstances: notably, in a pattern (or
the RHS of s///), if $4 exists then \4 is assumed to refer to that
rather than chr(4). "\04" is safer.

Good point. But I think \004 would be better, as it should be safe from
both $4 and from being followed by another digit.


How about Deparse's preferred version?

$ perl -MO=Deparse,-p -e 'print chr(4)'
print("\cD");

Are there hidden problems with that?

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top