in reply to Matching probem
OUTPUT:#!usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); local $/="\nCARS"; while (<DATA>){ my @lines = split /\n/ ,$_; my ($manufacturer, $vendor) = $lines[0] =~m/^(?:CARS)?\s+(\w+)\s+( +\w.+)/; print "----- Got car $manufacturer (Sold by $vendor) ---\n"; my @cars = grep {/^\+/} @lines; print "\tCAR: $_\n" for @cars; } __DATA__ 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.
----- Got car TOYOTO (Sold by Etios Innova Camry) --- CAR: +Fortuner Corolla ----- Got car HYUNDAI (Sold by Verna i10 i20) --- CAR: +Eon Xcent CAR: +Tucson ----- Got car HONDA (Sold by City Brio Amaze) --- CAR: +Accord
Once it hits the fan, the only rational choice is to sweep it up, package it, and sell it as fertilizer.
|
|---|