#!/usr/bin/perl -w use strict; use vars qw/ $i $filename @line @splitdata @data $out /; $i=1649; #Obtain name of file printf ("Please enter the name of file which you would like converted\n"); chomp ($filename=); printf "Filename inputted was %s\n", $filename; #Open data file, rid the new lines and store it to the line array open ( DATAFILE, "<", "$filename"); chomp (@line = ); close DATAFILE; #Read specific lines in while loop, split each part of each line, remove whitespace via pop at the start and the end of the line and store it to a new array called data while (defined($line[$i]) && $i < 3288){ @splitdata = split (/\s+/,$line[$i]); pop @splitdata; @splitdata =reverse(@splitdata); pop @splitdata; @splitdata =reverse(@splitdata); push @data, @splitdata; $i = $i + 1; } #Open an outfile and write the contents of data, in hexadecimal, into a binary format open (OUTFILE, ">","newfile"); binmode OUTFILE, ":raw"; foreach $out (@data){ printf OUTFILE ("%08x\n", $out); } close OUTFILE;