Skip to content

Instantly share code, notes, and snippets.

@jsarenik
Created April 2, 2014 16:25
Show Gist options
  • Save jsarenik/9937558 to your computer and use it in GitHub Desktop.
Save jsarenik/9937558 to your computer and use it in GitHub Desktop.
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