$/ = ";\n"; while(my $record = ) { my @rows = split("\n", $record); print "$rows[0]\n"; print "$rows[-2]\n"; } __DATA__ Begin Product A0001 Small gadget 5.00 0.00 0.25 0.00 No ; Tracking Inventory? /Images/gadget1.jpg ProdText\A0001.txt Begin Option Gadget Color Red Green Blue Yellow Black White End Option Begin Option Extra Attachment No Attachment Attachment ($5.00 extra) <+5.00> End Option End Product ; Begin Product A0002 Huge Widget 25.00 2.50 20.00 0.00 Yes ; Tracking Inventory? /Images/gadget2.jpg ProdText\A0002.txt Begin Option Widget Color Red Green Blue Yellow Black White End Option Begin Option Monogramming Include monogramming No monogramming End Option End Product ; Begin Product GPY01A1 GPY Angel 1 Print 8.5x11 140.00 0.00 1.00 3.00 ProdText\GPY01A1.txt SoftGoodControl: ::0:0 PriceCategory: Wholesale:114.00:114.00 Retail:114.00:114.00 Residential:114. End Product ; ##Results## Begin Product A0001 End Product Begin Product A0002 End Product Begin Product GPY01A1 End Product