/[webpac]/trunk/parse_format.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/parse_format.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Sun Feb 23 06:50:55 2003 UTC (16 years, 9 months ago) by dpavlin
File size: 1512 byte(s)
fixed parser, added support for 'mfn' field

1 dpavlin 10 #-------------------------------------------------------------
2     #
3     # parse_format('format',$isis_row);
4     #
5    
6     use isis_sf;
7    
8     sub parse_format {
9     my $format = shift;
10     my $row = shift;
11 dpavlin 23 my $i = shift || 0; # isis repeatable number
12 dpavlin 10
13     my $out;
14     my $out_swish;
15    
16     my $prefix = "";
17     if ($format =~ s/^([^\d]+)//) {
18 dpavlin 23 $prefix = $1;
19 dpavlin 10 }
20    
21     my $display;
22     my $swish;
23    
24     while ($format) {
25 dpavlin 23 #print STDERR "\n#### $format";
26 dpavlin 10 if ($format =~ s/^(\d\d\d)(\w?)//) {
27 dpavlin 23 my $isis_tmp = isis_sf($row,$1,$2,$i);
28 dpavlin 10 if ($isis_tmp) {
29     $display .= $prefix . $isis_tmp;
30     $swish .= $isis_tmp." ";
31 dpavlin 23 #print STDERR " == $isis_tmp";
32 dpavlin 10 }
33     $prefix = "";
34 dpavlin 22 # this might be our local scpeciality -- fields 10 and 11
35     # (as opposed to 010 and 011) so they are strictly listed
36     # here
37     } elsif ($format =~ s/^(1[01])//) {
38 dpavlin 23 my $isis_tmp = isis_sf($row,$1,undef,$i);
39 dpavlin 22 if ($isis_tmp) {
40     $display .= $prefix . $isis_tmp;
41     $swish .= $isis_tmp." ";
42     }
43     $prefix = "";
44 dpavlin 23 } elsif ($format =~ s/^mfn//i) {
45     $display .= $prefix . $row->{mfn};
46     $prefix = "";
47 dpavlin 10 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
48 dpavlin 23 $prefix .= $1 if ($display);
49 dpavlin 10 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
50 dpavlin 23 $prefix .= $1 if ($display);
51 dpavlin 10 } elsif ($format =~ s/^(\d{1,2})//) {
52 dpavlin 23 $prefix .= $1 if ($display);
53 dpavlin 10 } else {
54     print STDERR "unparsed format: $format\n";
55     $prefix .= $format;
56     $format = "";
57     }
58     }
59     # add suffix
60     $display .= $prefix if ($display);
61    
62     return ($swish,$display);
63     }
64    
65     #-------------------------------------------------------------
66     1;

Properties

Name Value
cvs2svn:cvs-rev 1.3

  ViewVC Help
Powered by ViewVC 1.1.26