Website hosting service by Active-Venture.com
  

 Back to Index

OPERATOR DIFFERENCES

The .. range operator treats certain character ranges with care on EBCDIC machines. For example the following array will have twenty six elements on either an EBCDIC machine or an ASCII machine:

 
    @alphabet = ('A'..'Z');   #  $#alphabet == 25  

The bitwise operators such as & ^ | may return different results when operating on string or character data in a perl program running on an EBCDIC machine than when run on an ASCII machine. Here is an example adapted from the one in perlop:

 
    # EBCDIC-based examples
    print "j p \n" ^ " a h";                      # prints "JAPH\n"
    print "JA" | "  ph\n";                        # prints "japh\n" 
    print "JAPH\nJunk" & "\277\277\277\277\277";  # prints "japh\n";
    print 'p N$' ^ " E<H\n";                      # prints "Perl\n";  

An interesting property of the 32 C0 control characters in the ASCII table is that they can "literally" be constructed as control characters in perl, e.g. (chr(0) eq "\c@") (chr(1) eq "\cA"), and so on. Perl on EBCDIC machines has been ported to take "\c@" to chr(0) and "\cA" to chr(1) as well, but the thirty three characters that result depend on which code page you are using. The table below uses the character names from the previous table but with substitutions such as s/START OF/S.O./; s/END OF /E.O./; s/TRANSMISSION/TRANS./; s/TABULATION/TAB./; s/VERTICAL/VERT./; s/HORIZONTAL/HORIZ./; s/DEVICE CONTROL/D.C./; s/SEPARATOR/SEP./; s/NEGATIVE ACKNOWLEDGE/NEG. ACK./;. The POSIX-BC and 1047 sets are identical throughout this range and differ from the 0037 set at only one spot (21 decimal). Note that the LINE FEED character may be generated by "\cJ" on ASCII machines but by "\cU" on 1047 or POSIX-BC machines and cannot be generated as a "\c.letter." control character on 0037 machines. Note also that "\c\\" maps to two characters not one.

 
    chr   ord  8859-1               0037                1047 && POSIX-BC     
    ------------------------------------------------------------------------
    "\c?" 127  <DELETE>             "                   "              ***><
    "\c@"   0  <NULL>               <NULL>              <NULL>         ***><
    "\cA"   1  <S.O. HEADING>       <S.O. HEADING>      <S.O. HEADING> 
    "\cB"   2  <S.O. TEXT>          <S.O. TEXT>         <S.O. TEXT>
    "\cC"   3  <E.O. TEXT>          <E.O. TEXT>         <E.O. TEXT>
    "\cD"   4  <E.O. TRANS.>        <C1 28>             <C1 28> 
    "\cE"   5  <ENQUIRY>            <HORIZ. TAB.>       <HORIZ. TAB.>    
    "\cF"   6  <ACKNOWLEDGE>        <C1 6>              <C1 6>   
    "\cG"   7  <BELL>               <DELETE>            <DELETE>   
    "\cH"   8  <BACKSPACE>          <C1 23>             <C1 23>
    "\cI"   9  <HORIZ. TAB.>        <C1 13>             <C1 13>
    "\cJ"  10  <LINE FEED>          <C1 14>             <C1 14>
    "\cK"  11  <VERT. TAB.>         <VERT. TAB.>        <VERT. TAB.>
    "\cL"  12  <FORM FEED>          <FORM FEED>         <FORM FEED>    
    "\cM"  13  <CARRIAGE RETURN>    <CARRIAGE RETURN>   <CARRIAGE RETURN> 
    "\cN"  14  <SHIFT OUT>          <SHIFT OUT>         <SHIFT OUT>
    "\cO"  15  <SHIFT IN>           <SHIFT IN>          <SHIFT IN>
    "\cP"  16  <DATA LINK ESCAPE>   <DATA LINK ESCAPE>  <DATA LINK ESCAPE> 
    "\cQ"  17  <D.C. ONE>           <D.C. ONE>          <D.C. ONE>
    "\cR"  18  <D.C. TWO>           <D.C. TWO>          <D.C. TWO>
    "\cS"  19  <D.C. THREE>         <D.C. THREE>        <D.C. THREE> 
    "\cT"  20  <D.C. FOUR>          <C1 29>             <C1 29> 
    "\cU"  21  <NEG. ACK.>          <C1 5>              <LINE FEED>    ***
    "\cV"  22  <SYNCHRONOUS IDLE>   <BACKSPACE>         <BACKSPACE>
    "\cW"  23  <E.O. TRANS. BLOCK>  <C1 7>              <C1 7>
    "\cX"  24  <CANCEL>             <CANCEL>            <CANCEL>
    "\cY"  25  <E.O. MEDIUM>        <E.O. MEDIUM>       <E.O. MEDIUM>
    "\cZ"  26  <SUBSTITUTE>         <C1 18>             <C1 18>
    "\c["  27  <ESCAPE>             <C1 15>             <C1 15>
    "\c\\" 28  <FILE SEP.>\         <FILE SEP.>\        <FILE SEP.>\
    "\c]"  29  <GROUP SEP.>         <GROUP SEP.>        <GROUP SEP.>
    "\c^"  30  <RECORD SEP.>        <RECORD SEP.>       <RECORD SEP.>  ***><
    "\c_"  31  <UNIT SEP.>          <UNIT SEP.>         <UNIT SEP.>    ***><
  

 

  

 

Domain name registration - 
Register cheap domain name from $7.95 and enjoy free domain services 
 

Cheap domain name search service -
Domain name services at just
$8.95/year only
 

Register domain name -
Buy domain name registration and cheap domain transfer at low, affordable price.

© 2002-2004 Active-Venture.com Web Site Hosting Service

 

[ You know you're a geek when... You try to shoo a fly away from the monitor with your cursor. That just happened to me. It was scary.   ]

 

 
 
 

Disclaimer: This documentation is provided only for the benefits of our web hosting customers.
For authoritative source of the documentation, please refer to http://www.perldoc.com