in reply to Buffered read and matching
Use $/ to skip over the bits you aren't interested in:
#! perl -slw use strict; $/ = "'Errors'"; while( my $junk = <DATA> ) { local $/ = "\n["; my $errorData = <DATA>; last unless $errorData; chop $errorData; print "'Errors' $errorData"; } __DATA__ [2008/10/14 10:57:18] [55] DEBUG Austin::API::vendor_api - Initialisin +g the APIGalileo [2008/10/14 10:57:18] [41] DEBUG Austin::Suppliers::Common::Location:: +init - Setting Up Generic Locations [2008/10/14 11:15:22] [147] DEBUG Austin::Controller::default - $VAR1 += { 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] }; [2008/10/14 10:57:18] [245] DEBUG Austin::XV::Trip::set_time_zone - Ch +ecking timezone with agent UK [2008/10/14 10:57:18] [247] DEBUG Austin::XV::Trip::set_time_zone - Se +tting timezone to Europe/London [2008/10/14 11:15:22] [2008/10/14 11:15:22] [147] DEBUG Austin::Controller::default - $VAR1 += { 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] }; [2008/10/14 11:15:22]
Outputs:
c:\test>junk1 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] }; 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] };
|
|---|