open (FH,"$file") || die ("could not openfile"); my @arr; while () { chomp; push @arr , $_ unless $_ !~ /\s+\/\// ; } foreach (@arr){ s/^\s+//g; s/^-\/\/.+//g; print $_."\n"; } Thanks in advance.