Mr. Shawn H. Corey wrote:
On Thu, 2008-09-04 at 17:54 -0400, Moon, John wrote:
Does anyone know the octal code for what vi is showing as "^L"? I tried
"\n\r" & \r\n" but that does not seem to be the same... I am on a UNIX
box... I need the octal code to add to the beginning of first record
written from my perl script... I'm using "write" and "format" and need
ALL headers to be alike... the first is w/out the "^L"...

use Perl;

#!/usr/bin/perl

use strict;
use warnings;

my $char = 'L';

my $ctrl_code = ord( $char ) - ord( '@' );
print  "control code: ^$char\n";
printf "decimal:      %d\n", $ctrl_code;
printf "octal:        \\%03o\n", $ctrl_code;
printf "hexadecimal:  \\x%02x\n", $ctrl_code;

my $ctrl_code = ord( $char ) - ord( '@' );
printf <<'FORMAT', $char, $ctrl_code;
control code: ^%s
decimal:      %d
octal:        \%2$03o
hexadecimal:  \x%2$02x
FORMAT


;-)


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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to