Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What is abriviation for CHR(4)

Reply
Thread Tools

What is abriviation for CHR(4)

 
 
max
Guest
Posts: n/a
 
      03-07-2007
Problem with making Replacement CHR(4) in something.
CHR(9) is "\t"
I use tr///.
What is abbreviation for CHR(4)

Thanks

Max


 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      03-07-2007
max wrote:
> 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
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      03-08-2007
max <> wrote:

> CHR(9) is "\t"



No it isn't, CHR(9) is an error.

perl -e 'CHR(9)'
Undefined subroutine &main::CHR called at -e line 1.

Case matters.


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
max
Guest
Posts: n/a
 
      03-08-2007
Thanks
Super is easier that I think.

Max

"John W. Krahn" <> wrote in message
news:JNFHh.35312$cE3.33296@edtnps89...
> max wrote:
> > 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
> --
> Perl isn't a toolbox, but a small machine shop where you can special-order
> certain sorts of tools at low cost and in short order. -- Larry Wall



 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-08-2007
"max" <> wrote:
> 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:umper; $Data:umper::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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      03-08-2007

Quoth :
> "max" <> wrote:
> > 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:umper; $Data:umper::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

--
"Faith has you at a disadvantage, Buffy."
"'Cause I'm not crazy, or 'cause I don't kill people?"
"Both, actually."
[]
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-09-2007
Ben Morrow <> wrote:
> Quoth :
> > "max" <> wrote:
> > > 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:umper; $Data:umper::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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57