1: #!/usr/local/bin/perl -w
2:
3: use strict;
4:
5: sub OAIv_findPlatform {
6: my $platform = shift @_;
7: chomp $platform;
8:
9: # Default Platform Type is 0 (Unknown)
10: my $platformType = "0";
11:
12: # If multiple platforms match, it's cross platform
13: my $isCrossPlatform;
14: $isCrossPlatform=0;
15:
16: if ( $platform =~ /^(.*)HTML Browser(.*)$/ ) {
17: $platformType="5";
18: $isCrossPlatform=$isCrossPlatform+1;
19: }
20: if ( $platform =~ /^(.*)Java Virtual Machine(.*)$/ ) {
21: $platformType="64";
22: $isCrossPlatform=$isCrossPlatform+1;
23: }
24: if ( $platform =~ /^(.*)PC(.*)$/ ) {
25: $platformType="3";
26: $isCrossPlatform=$isCrossPlatform+1;
27: }
28: if ( $platform =~ /^(.*)Sun Sparc(.*)$/ ) {
29: $platformType="36";
30: $isCrossPlatform=$isCrossPlatform+1;
31: }
32: if ( $platform =~ /^(.*)SGI(.*)$/ ) {
33: $platformType="81";
34: $isCrossPlatform=$isCrossPlatform+1;
35: }
36: if ( $platform =~ /^(.*)HP(.*)$/ ) {
37: $platformType="82";
38: $isCrossPlatform=$isCrossPlatform+1;
39: }
40:
41: if ( $isCrossPlatform >= 2 ) {
42: $platformType="1";
43: }
44:
45: return $platformType;
46: }
47:
48: sub OAIv_findLContext () {
49: my @gradelevels;
50: foreach my $grade (@_) {
51: if ( $grade eq "Primary elementary" ) {
52: push(@gradelevels,"1","2","3");
53: } elsif ( $grade eq "Intermediate elementary" ) {
54: push(@gradelevels,"4","5","6");
55: } elsif ( $grade eq "Primary Education" ) {
56: push(@gradelevels,"1","2","3","4","5","6");
57: } elsif ($grade eq "Middle school" ){
58: push(@gradelevels,"7","8");
59: } elsif ( ($grade eq "Secondary Education") or ($grade eq "High school") ) {
60: push(@gradelevels,"9","10","11","12");
61: } elsif ($grade eq "Undergraduate lower division") {
62: push(@gradelevels,"13","14");
63: } elsif ($grade eq "Undergraduate upper division") {
64: push(@gradelevels,"15","16");
65: } elsif ( $grade eq "Higher Education" ) {
66: push(@gradelevels,"13","14","15","16");
67: } elsif ( $grade eq "Graduate or professional" ) {
68: push(@gradelevels,"17");
69: } else {
70: }
71: }
72: if (@gradelevels) {
73: return join(";", @gradelevels);
74: } else {
75: return();
76: }
77: }
78:
79: sub OAIv_parseVcard_matti () {
80: # Sample begin:vcard FN: Richard N: Wellman ADR: ;Salt Lake City, UT 84124;;;;;USA ORG: Westminster College EMAIL; INTERNET: rwellman@westminstercollege.edu end:vcard
81: my $firstname;
82: my $lastname;
83: my $email;
84: my $org;
85: my @pdi;
86:
87: ($firstname, $lastname, $org, $email) = (shift(@_) =~ /^begin:vcard\sFN:\s(.*)\sN:\s(.*)\sADR:.*ORG:\s(.*)\sEMAIL;\sINTERNET:\s(.*)\send:vcard$/);
88:
89: push(@pdi,$lastname, $firstname, $email, $org);
90: return @pdi;
91:
92: }
93:
94: sub OAIv_parseVcard () {
95: # Sample
96: #BEGIN:vCard
97: #FN:Steve Hayes
98: #N:Hayes;Steve
99: #EMAIL;INTERNET:shayes@vt.edu
100: #ORG:Virginia Tech;Computer Science
101: #END:vCard
102: my $firstname;
103: my $lastname;
104: my $email;
105: my $org;
106: my @pdi;
107:
108: my @vcard = split /\n/, shift(@_);
109: foreach my $element (@vcard) {
110: chomp $element;
111: my ($property,$value) = split /:/, $element;
112: next if ! defined $property;
113: if ( $property eq "FN" ) {
114: ($firstname,$lastname) = split / /, $value;
115: } elsif ( $property eq "EMAIL;INTERNET" ) {
116: $email = $value;
117: } elsif ( $property eq "ORG" ) {
118: $org = $value;
119: }
120: }
121:
122: push(@pdi,$lastname, $firstname, $email, $org);
123: return @pdi;
124: }
125:
126: return 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>