Custom Search
www.rocket99.com : Technical Guides Sybase Oracle UNIX Javascript


Technical Guides
Sybase
Oracle
UNIX
Javascript




Of Interest

Business Intelligence and Analytics



Oracle Training





UNIX » Perl » Coding »

Binary File Viewer

     




#!/usr/bin/perl
#--------------------------------------------
# Display file in PCTOOLS ASCII mode
#--------------------------------------------

$file1 = $ARGV[0];

$size1 = -s $file1 ;

open(FILE1,"<$file1") or die "Input file: Cannot open file\n\n";

$i = 0 ;
$j = 0 ;

while ($i < $size1 )
{
$ch = getc(FILE1);

$part1 = $part1 . ' ' . $ch ;
$part2 = $part2 . ' ' . ord($ch) ;

$i ++ ;
$j ++ ;

if ($j==20)
{
$part1 =~ s/\n/\*/g ;
$part1 =~ s/\r/\*/g ;
$part1 =~ s/\t/\*/g ;
print $part1 . ' ' . $part2 . "\n" ;
$part1 = '' ;
$part2 = '' ;
$j = 0 ;
}

}

if ($j>0)
{
$part1 =~ s/\n/\*/g ;
$part1 =~ s/\r/\*/g ;
$part1 =~ s/\t/\*/g ;
print $part1 . ' ' . $part2 . "\n" ;
}

close(FILE1);











UNIX : Related Topics

UNIX : Perl : Text file processor - sewing paragraphs together
UNIX : Perl : CSV File Processor
UNIX : Perl : Replace characters in a file via Perl utility
UNIX : Perl : Remove exponents in a floating number
UNIX : Perl : Set precision of a numeric string
UNIX : Perl : Parse command line options
UNIX : Perl : HTML directive for Perl CGI
UNIX : Perl : Compare Two Binary Files
UNIX : Perl : Binary File Cutter
UNIX : Perl : Arrays and Lists
UNIX : Perl : Getting IP and Network Detail in Perl

Sybase Web Site
Sybase iAnywhere Mobile Web Site
Oracle Enterprise Web Site



Get the latest Rocket99 news and tech tips via






Site Index About this Guide to Sybase, Oracle, and UNIX Contact Us Advertise on this site




Copyright © 2016 Stoltenbar Inc All Rights Reserved.