use strict; use warnings; #### CARS TOYOTO Etios Innova Camry +Fortuner Corolla *.This is Class cars. CARS HYUNDAI Verna i10 i20 +Eon Xcent +Tucson *.It is best cars. CARS HONDA City Brio Amaze +Accord *.This is Luxury cars. #### #!usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); open(DATA,"/something/something/something") || die("Couldnt open the file \n"); while() { if(/^\s*CARS\s*[A-Z]/) { ($car)=$_=/^\s*CARS\s*(\w+)/; push(@car_list,$car); } } foreach $one_car(@car_list) { open(DATA,"/something/something/something")|| die("Couldnt open the file \n"); while() { if(/^\s*CARS\b$one_car\b/) { last if/\*\.(\w+)/; $/="*"; $data_next=; print"$data_next\n"; $/="\n"; } } }