What is abriviation for CHR(4)

Discussion in 'Perl Misc' started by max, Mar 7, 2007.

  1. max

    max Guest

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

    Thanks

    Max
     
    max, Mar 7, 2007
    #1
    1. Advertising

  2. 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
     
    John W. Krahn, Mar 7, 2007
    #2
    1. Advertising

  3. 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
     
    Tad McClellan, Mar 8, 2007
    #3
  4. max

    max Guest

    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
     
    max, Mar 8, 2007
    #4
  5. max

    Guest

    "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::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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Mar 8, 2007
    #5
  6. max

    Ben Morrow Guest

    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::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

    --
    "Faith has you at a disadvantage, Buffy."
    "'Cause I'm not crazy, or 'cause I don't kill people?"
    "Both, actually."
    []
     
    Ben Morrow, Mar 8, 2007
    #6
  7. max

    Guest

    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::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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Mar 9, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. crjunk
    Replies:
    2
    Views:
    16,842
    crjunk
    Aug 8, 2003
  2. Andi Twine
    Replies:
    3
    Views:
    549
    Natty Gur
    Jan 13, 2004
  3. =?Utf-8?B?RGFuIE5hc2g=?=

    C# equiv of Chr(13)

    =?Utf-8?B?RGFuIE5hc2g=?=, Nov 1, 2004, in forum: ASP .Net
    Replies:
    12
    Views:
    74,322
    Dudeman3000
    Feb 22, 2010
  4. ProJee
    Replies:
    3
    Views:
    442
    ProJee
    Nov 17, 2004
  5. MattB
    Replies:
    3
    Views:
    554
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Nov 19, 2004
Loading...

Share This Page