#!/usr/bin/perl

use strict;
use Switch;

my $in_code = 0;

binmode STDIN;

my $buffer;
my $bigbuffer;
my $char;
my %chars;

while (read(STDIN, $buffer, 65536)) {
  warn "read one buffer\n";
  $bigbuffer .= $buffer;
#  while(length($bigbuffer) > 100) {
    while ($bigbuffer =~ s/^.*?architecture/architecture/s) {
      warn "  one archi\n";
      while ($bigbuffer =~ s/^([[:print:]\n\t]+})//s) {
        warn "  one match, len is " . length($bigbuffer) . "\n";
        print $1 . "\n";
      }
    }
#  }
  warn "Size remaining in buffer is ". length($bigbuffer). "\n";
}


#      foreach $char (split //,$buffer) {
#      $chars{$char} ++;
#      if ($char =~ /[[:print:]\n\t]/) {
#        print $char;
#      }
#print "\nStats:\n";

#foreach $char (sort keys %chars) {
#  if ($char =~ /[[:print:]]/) {
#    print "$chars{$char} times '$char'\n";
#  } else {
#    my $hex = unpack ("H*",$char);
#    print "$chars{$char} times '0x$hex'\n";
#  }
#}

#warn "Problem copying: $!\n" if $!;

#close OUTF
#  or die "Can't close $destfile: $!\n";
#close INF
#  or die "Can't close $srcfile: $!\n";

