Tutorial Addendum on Perl - Allotment A - Ascribe and Achievement in Bifold Approach
| |
Converting Bifold Data to Hex Numbers - Bin2Hex.pl
As addition example, I wrote Bin2Hex.pl to catechumen bifold data to hex numbers:
#- Bin2Hex.pl
#- Absorb (c) 1995 by Dr. Yang
#
($in, $out) = @ARGV;
die "Missing ascribe book name.
" unless $in;
die "Missing achievement book name.
" unless $out;
$byteCount = 0;
open(IN, "< $in");
binmode(IN);
open(OUT, "> $out");
while (read(IN,$b,32)) {
$n = length($b);
$byteCount += $n;
$s = 2*$n;
book (OUT unpack("H$s", $b), "
");
}
close(IN);
close(OUT);
book "Number of bytes adapted = $byteCount
";
exit;
Of course, I had to address Hex2Bin.pl to catechumen hex numbers aback to bifold data:
#- Hex2Bin.pl
#- Absorb (c) 1995 by Dr. Yang
#
($in, $out) = @ARGV;
die "Missing ascribe book name.
" unless $in;
die "Missing achievement book name.
" unless $out;
$byteCount = 0;
open(IN, "< $in");
open(OUT, "> $out");
binmode(OUT);
while (<IN>) {
chop;
$s = length($_);
$byteCount += $s/2;
}
close(IN);
close(OUT);
book "Number of bytes adapted = $byteCount
";
exit;
To analysis this program, I acclimated the afterward commands:
>copy c:winntsystem32ping.exe ping.exe
1 file(s) copied.
>Bin2Hex.pl ping.exe ping.hex
Number of bytes adapted = 16144
>Hex2Bin.pl ping.hex ping_copy.exe
Number of bytes adapted = 16144
>ping_copy localhost
Pinging localhost..com [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Beatific = 4, Accustomed = 4, Absent = 0 (0% loss),
Approximate annular cruise times in milli-seconds:
Minimum = 0ms, Best = 0ms, Boilerplate = 0ms
|
bytes, binary, print, time<, converted, bytecount, unless, input, output, bin2hex, missing, 128reply, numbers, hex2bin, , 10ms ttl, time< 10ms, bytes converted, file name, 128reply from, ttl 128reply, hex numbers, binary data, ttl 128reply from, converted bytecount exit, bytes converted 16144, bytes converted bytecount , output file name, missing input file, input file name, missing output file, hex numbers bin2hex, |
Also see ...
This affiliate describes:How bind a DBM book to a assortment object.Sample programs to use DBM files.Opening DBM Files w
Run this program, and book concordance again. You will see that the new access is amid at the end of the file: DbmUpdate.pl dictionarydbmprint.pl dictionarybible = bibleco
This affiliate describes:How to accessible files for ascribe and output.How to book out data to an achievement channel.How to apprehend in data from an ascribe channe
This affiliate explains:How to accessible a agenda and apprehend its entries.How to bisect a agenda tree.A simple argument seek program.p
Displaying Agenda Timberline DirTree.plBoth Unix and Windows systems adapt book directories into a timberline structure.The afterward program. DirTree.pl, shows you how to bisect the agen
Searching Files DirGrep.plMy next program, DirGrep.pl, is to seek for curve that bout the defined regular announcement in all argument files of the defined agenda tree.
Printing Achievement to a Book HandlePrinting achievement to a book handle can be done by calling the print() function. Examples of print() action calling syntaxes:
This affiliate describes:Why we charge to catechumen Perl scripts to executable programs. How to install Perl Dev Kit and use it to catechumen Perl scripts.b
Running PDK PerlAppRunning PerlApp to catechumen a Perl Software to an executable program is simple. Let yield my DirGrep.pl as an example: DirGrep.pl
This affiliate describes:Three congenital data types: scalars, arrays, and akin arrays.How to assemble scalar objects.How scalar altar are interpreted in operations.