source: trunk/soft/ObsData/ourplugins/cr_lid_lor.pl @ 250

Last change on this file since 250 was 250, checked in by thetis, 18 years ago

hack: return early if name does not match to avoid useless noise

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2
3# $Id$
4
5use strict;
6
7sub {
8    my ($rda, $plugintype, $datafile, $datatype) = @_;
9
10    $datafile =~ /CRE/ or return(0);
11    my $archive = $rda->archive() or do {
12        $rda->logging(4,
13            'Can get archive'
14        );
15        return(0);
16    };
17 
18    my $filename = $archive->extract() or do {
19        $rda->logging(4,
20            "Can't get temporary file: %s",
21            $archive->error || "",
22        );
23        return(0);
24    };
25   
26    my $resopen = open(my $h, $filename);
27   
28    unlink($filename);
29
30    if (!$resopen) {
31        $rda->logging(4,
32            "Can't open temp file %s",
33            $filename,
34        );
35        return(0);
36    }
37
38    while (my $line = <$h>) {
39        chomp($line);
40        if ($line =~ /^Numero\s+\|Nom\s+\|Voies actives/) {
41            my $nextline = <$h>;
42            chomp($nextline);
43            $nextline =~ /^1\s*\|E(\d)\d{6}\.?N\d{4}/;
44            if ($1) {
45                return(1,
46                    'mode', $1,
47                );
48            } else {
49                $rda->logging(4,
50                    "can't find marker: %s",
51                    $nextline,
52                );
53                return(0);
54            }
55        }
56    }
57
58    close($h);
59   
60    return(0);
61}
62
Note: See TracBrowser for help on using the repository browser.