#!/usr/bin/perl # TODO: # 1. input file on command line # 2. output to a file use strict my ($buf, @temp_file, @in_file, @out_file, $first, $second, $third, $fourth, $fifth, $openme, $length, $pad_file, $count, $max_length, $t, $u, $v,$w, $x, $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 ("w-dimension : "); $w = ; print ("x-dimension : "); $x = ; $size = ($t*$u*$v*$w*$x); 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++) { $count++; $temp_file[$first][$second][$third][$fourth][$fifth] = $in_file[$count]; } } } } } print ("\n\n"); $count = 0; 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++; $out_file[$count] = $temp_file[$first][$second][$third][$fourth][$fifth]; } } } } } $count = 0; for ($count = 1; $count <= $size; $count++) { print ($out_file[$count]); if ($count % 70 == 0) { print ("\n"); } } print ("\n\n");