#!perl use strict; # because we should use warnings; # because we should use autodie; # die if problem reading or writing a file my $input = 'C:/MIG6/Uploadfiles/Input/AllRAW.txt'; # where to get data my $dir = 'C:/MIG6/Uploadfiles/Output'; # where to put the new files open FILEin, $input; binmode(FILEin); while (my $line = ){ if ($line =~ /^"EE",/){ my $search = index($line,'54250213200'); $search += 16; my $dgo = substr($line,$search,13); $search += 16; my $ean = substr($line,$search,18); my $outfile = $dir.'/e07_'.$dgo.'_err_b2c_MIG6testing_'.$ean.'.txt'; open FILEout, '>'.$outfile; print FILEout $line; } else { print FILEout $line; } } close FILEout; close FILEin; exit 0; # all done, let's have some cake!