Try this:
my @inArray, @outArray ;
open(IN, '<yourfile.txt') ;
@inArray = <IN> ;
close(IN) ;
foreach my $tmpLine (@inArray) {
my ($id, $name, $att, $yesno) = ($tmpLine =~ m!(.+),(.+),(.+),(Y|N)!i) ;
push(@outArray, $tmpLine) ;
if ($yesno eq "Y") {
push(@outArray...