source: projects/perl-tools/strip-null-bytes.old.pl @ 27

Last change on this file since 27 was 2, checked in by sven, 16 years ago

Verschiedenste Änderungen getätigt (und Subversion nicht richtig bedient),
daher leicht zerschossene working copy -- zunächst also commit der
unkomplizierten Dinge (perl-tools) und später commit der komplizierten
Dinge (visualisator sowie Verzeichnisumstellungen bei puncher-dirs).
Zwischenzeitlich werde ich eine working copy auf meine neue
ext3 DATA-Partition erstellen.

  • Property svn:executable set to *
File size: 907 bytes
Line 
1#!/usr/bin/perl
2#
3# Strippt Nullbytes vorne und hinten von STDIN-Daten
4# oder Parameter (Datei) weg.
5#
6
7sub nichtdas {
8my @data = split/\s+/, join ' ', <>;
9
10# strip at beginning
11$x=0;
12for(@data) {
13$x++;
14    print STDERR "$x: $_\n";
15    unless( /^00?$/ ) {
16        print STDERR "$x: $_ No more nullbytes.\n";
17    }
18
19    last unless /^00?$/;
20    shift(@data);
21}
22
23#@data = reverse(@data);
24#do STRIP;
25#@data = reverse(@data);
26
27map { print pack("C", hex $_) } @data;
28
29}#sub
30
31#!/usr/bin/perl
32#
33#
34#
35#
36
37use bytes;
38use strict;
39my $x_start;
40my $x_end;
41
42my $bytes = join '', <>; # bytestring mit STDINSTREAM
43
44#map { $bytes .= chr } (0, 12, 25, 2, 3);
45##my $bytes = chr(0x00),chr(0x12.0x25;
46
47
48for($x_start = 0; $x_start < length($bytes); $x_start++) {
49  print "Byte $x_start: ".ord(substr($bytes, $x_start, 1)), "\n";
50  last unless substr($bytes, $x_start, 1) == 0x00;
51}
52
53print "Vorne gehts los nach Byte $x_start\n";
54
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License