#!/usr/bin/perl # TODO: # 1. input file on command line # 2. output to a file use strict my ($buf, @out_file, @in_file, $first, $second, $third, $fourth, $fifth, $sixth, $seventh, $length, $openme, $pad_file, $count, $max_length, $t, $u, $v,$w, $x, $y, $z, $size); $max_length = 1000000; print ("\nfile : "); $openme = ; $count = 0; open(IN,"$openme") || die "Sorry. Couldn't open: $!\n"; while (read (IN, $buf, 1)) { if (($buf eq " ") or ($buf eq "\t")) { $buf = "\n"; } if (($buf ne "\n") && ($count < $max_length)) { $count++; $in_file[$count] = $buf; } } $length = $count; print ("\nlength is : $count\n"); close (IN); print ("t-dimension : "); $t = ; print ("u-dimension : "); $u = ; print ("v-dimension : "); $v = ; print ("\nw-dimension : "); $w = ; print ("x-dimension : "); $x = ; print ("y-dimension : "); $y = ; print ("z-dimension : "); $z = ; $size = ($t*$u*$v*$w*$x*$y*$z); print ("\nsize is : $size\n"); if ($size < $length) { print ("\nsize is smaller than the file. Proceeding anyway."); } if ($size > $length) { $count = 0; print ("\nsize is larger than the input. Pad file: "); $pad_file = ; open(IN,"$pad_file") || die "Sorry. Couldn't open: $!\n"; while (read (IN, $buf, 1)) { if (($buf eq " ") or ($buf eq "\t")) { $buf = "\n"; } if (($buf ne "\n") && ($count < $size)) { $count++; $in_file[$count] = $buf; } } $count = 0; open(IN,"$openme") || die "Sorry. Couldn't open: $!\n"; print ("\nrereading $openme\n"); while (read (IN, $buf, 1)) { if (($buf eq " ") or ($buf eq "\t")) { $buf = "\n"; } if (($buf ne "\n") && ($count < $max_length)) { $count++; $in_file[$count] = $buf; } } } close (IN); $count = 0; for ($first = 1; $first <= $t; $first++) { for ($second = 1; $second <= $u; $second++) { for ($third = 1; $third <= $v; $third++) { for ($fourth = 1; $fourth <= $w; $fourth++) { for ($fifth = 1; $fifth <= $x; $fifth++) { for ($sixth = 1; $sixth <= $y; $sixth++) { for ($seventh = 1; $seventh <= $z; $seventh++) { $count++; $out_file[$first][$second][$third][$fourth][$fifth][$sixth][$seventh] = $in_file[$count]; } } } } } } } print ("\nCOUNT was : $count\n"); $count = 0; for ($seventh = 1; $seventh <= $z; $seventh++) { for ($sixth = 1; $sixth <= $y; $sixth++) { for ($fifth = 1; $fifth <= $x; $fifth++) { for ($fourth = 1; $fourth <= $w; $fourth++) { for ($third = 1; $third <= $v; $third++) { for ($second = 1; $second <= $u; $second++) { for ($first = 1; $first <= $t; $first++) { $count++; print ($out_file[$first][$second][$third][$fourth][$fifth][$sixth][$seventh]); } } } } } } } print ("\ncount out was : $count\n"); print ("\n\n");