/[webpac]/branches/tehnika/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

Contents of /branches/tehnika/parse_format.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Sun Feb 23 06:50:55 2003 UTC (21 years, 1 month ago) by dpavlin
Original Path: trunk/parse_format.pm
File size: 1512 byte(s)
fixed parser, added support for 'mfn' field

1 #-------------------------------------------------------------
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 my $i = shift || 0; # isis repeatable number
12
13 my $out;
14 my $out_swish;
15
16 my $prefix = "";
17 if ($format =~ s/^([^\d]+)//) {
18 $prefix = $1;
19 }
20
21 my $display;
22 my $swish;
23
24 while ($format) {
25 #print STDERR "\n#### $format";
26 if ($format =~ s/^(\d\d\d)(\w?)//) {
27 my $isis_tmp = isis_sf($row,$1,$2,$i);
28 if ($isis_tmp) {
29 $display .= $prefix . $isis_tmp;
30 $swish .= $isis_tmp." ";
31 #print STDERR " == $isis_tmp";
32 }
33 $prefix = "";
34 # 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 my $isis_tmp = isis_sf($row,$1,undef,$i);
39 if ($isis_tmp) {
40 $display .= $prefix . $isis_tmp;
41 $swish .= $isis_tmp." ";
42 }
43 $prefix = "";
44 } elsif ($format =~ s/^mfn//i) {
45 $display .= $prefix . $row->{mfn};
46 $prefix = "";
47 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
48 $prefix .= $1 if ($display);
49 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
50 $prefix .= $1 if ($display);
51 } elsif ($format =~ s/^(\d{1,2})//) {
52 $prefix .= $1 if ($display);
53 } 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