Created
          April 2, 2014 16:25 
        
      - 
      
- 
        Save jsarenik/9937558 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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