#!/usr/bin/perl use strict; use warnings; ### open(FILEIN, "table.txt"); #numbers table which only has 0 and 1. ### let's read from __DATA__ instead (try adding your own DATA...) open FILEOUT, ">>data.txt" or die "data.txt: $!\n"; ### opens data.txt in output/append mode my @seed = split //, "01110011001111100010111101011111000100110"; my $expected = scalar @seed; while () { ### reads line by line from DATA which is provided below chomp; ### you do want to chomp the input if ( ! /^[01]+$/ ) { warn "input line $. has characters other than 0 and 1\n"; next; } my $length = length(); if ( $length != @seed ) { warn "input line $. has $length digits instead of $expected\n"; } my $count = 0; for my $digit ( split // ) { $seed[$count++] -= $digit; } print FILEOUT "@seed\n"; #shows you what we have read } ### close FILEIN; close FILEOUT; __DATA__ 01110011001111100010111101011111000100110 01110011001111100010111101011111000100110 1110011001111100010111101011111000100110 0011100110011111000101111010111110001001101 012345 xyz