Skip to content

Instantly share code, notes, and snippets.

@jsarenik jsarenik/parse.pl
Created Apr 2, 2014

Embed
What would you like to do?
open F, $opt{src_file} or die "Cannot open file `$opt{src_file}': $!";
my $counter=0;
my $record = "";
while (<F>) {
$counter++, process_record($record), $record = "" if /\d{4}\.\d{2}\.\d{2} \d
$record .= $_;
}
# Process last record
$counter++, process_record($record), $record="" if $record ne "";
close F or warn "Cannot close file `$opt{src_file}': $!";
sub process_record {
$_[0] =~ s/^\s*|\s*$//;
my(@record) = split /\s*\|\s*/, shift;
$record[5] =~ /^Some text:(\d+) - (\w+): (<.*)/;
@record[5,6,7] = ($1,$2,$3);
s#\>\s+#>#g, s#\s+\<#<#g for $record[7];
warn join ";", @record;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.