A1,A2,A3,A4 B1,B2,B3,B4 1,Just some data,c29tZSBzdHJpbmc= C1,C2,C3,C4 D1,VGhpcyBpcyBkZWNvZGVkIQ==,D3,D4,GibberishdlkfjsDKjdlslksJAoiasosaSDSD== #### #csvDecode.pl VERSION 1 #Written by Andrew Hoyt #Takes LogData from the MSS Portal and decodes the base64 characters (assuming there is any base64 to be decoded, and if so, that it's in column eleven). #!/usr/bin/perl use strict; use warnings; use Text::CSV; use MIME::Base64; my $i=0; my @columns; my @cleanData; my @input; my $file = 'data.csv'; my $csv = Text::CSV->new(); open (CSV, "<", $file) or die $!; my $string; while () { if ($csv->parse($_)) { @columns = $csv->fields(); #my $numCols = $#columns; #print "($numCols)\n"; } else { my $err = $csv->error_input; print "Failed to parse line: $err"; } foreach (@columns){ $_ = check($_); $cleanData[$i] = $_; $i++; print $_; } print "\n"; } close CSV; open (MYFILE, ">", "output.csv") or die $!; foreach (@cleanData){ print MYFILE "$_,"; #print MYFILE "\n"; } #print MYFILE "\n"; close MYFILE; sub check{ my $col = shift; $col = decode_base64($col) if m{ ^ (?: [A-Za-z0-9+/]{4} )* (?: [A-Za-z0-9+/]{2} [AEIMQUYcgkosw048] = | [A-Za-z0-9+/] [AQgw] == )? $ }x; return $col; } #### A1,A2,A3,A4,B1,B2,B3,B4,1,Just some data,some string,C1,C2,C3,C4,D1,This is decoded!,D3,D4,GibberishdlkfjsDKjdlslksJAoiasosaSDSD==,