File: NoSQL-11.html

package info (click to toggle)
nosql 0.9-0
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,364 kB
  • ctags: 225
  • sloc: perl: 3,766; sh: 476; makefile: 41
file content (143 lines) | stat: -rw-r--r-- 3,548 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN">
<HTML>
<HEAD>
<TITLE>NoSQL: Examples of perl expressions and statements</TITLE>
</HEAD>
<BODY>
<A HREF="NoSQL-10.html">Previous</A>
<A HREF="NoSQL-12.html">Next</A>
<A HREF="NoSQL.html#toc11">Contents</A>
<HR>
<H2><A NAME="s11">11. Examples of perl expressions and statements</A>  </H2>

<P>Following are some examples of PERL expressions and
statements of the type that might be used with NoSQL operators,
and their meaning.  Note that the operator 'nsq-row' takes
a PERL expression while the operator 'nsq-compute' takes a
complete PERL statement.
<P>Expressions:
<P>
<BLOCKQUOTE><CODE>
<PRE>
    
    COLA mat /XXX/
    
                   -- column COLA contains the pattern 'XXX'.
    
    COLA nmat /XXX/
    
                   -- column COLA does NOT contain the pattern 'XXX'.
    
    COLA mat /^XXX/
    
                   -- column COLA starts with the pattern 'XXX'.
    
    COLA mat /XXX$/
    
                   -- column COLA ends with the pattern 'XXX'.
    
    COLA ne null
    
                   -- column COLA is not null (but it could contain blanks).
    
    COLA mat /^\s*$/
    
                   -- column COLA is null or contains only blank space.
    
    COLA eq 'YYY'
    
                   -- column COLA equals the literal 'YYY'.
    
    COLA mat /X..Y/
    
                   -- column COLA contains the pattern 'X..Y', which means
                      'X', followed by any two characters, then 'Y'.
    
    COLA mat /X.*Y/
    
                   -- column COLA contains the pattern 'X.*Y', which means
                      'X', followed by any number of (including zero)
                      characters, then 'Y'.
    
    NUMC eq 12
    
                   -- column NUMC equals 12.
    
    COLA ne null && COLB ne null
    
                   -- column COLA and column COLB are not null (empty).
    
    COLA eq 'ABC' || COLA eq 'BCD'
    
                   -- column COLA equals the literal 'ABC' or column COLB
                      equals the literal 'BCD'
    
    
  
</PRE>
</CODE></BLOCKQUOTE>
<P>Statements:
<P>
<BLOCKQUOTE><CODE>
<PRE>
    
    COLA = COLB ;
    
                   -- set the value of column COLA to that of COLB.
    
    NUMC = NUMC - 7 ;
    
                   -- decrement the value of column NUMC by 7.
    
    NUMC -= 7 ;
    
                   -- (same as above).
    
    NUMC = NUMC / 4 ;
    
                   -- divide the value of column NUMC by 4.
    
    NUMC *= 2.3 ;
    
                   -- multiply the value of column NUMC by 2.3.
    
    $abc++ ;
    
                   -- increment the value of variable $abc by 1.
    
    ++$abc ;
    
                   -- (same as above).

    COLA = 'WORDS' ;
    
                   -- set the value of column COLA to the literal 'WORDS'.
    
    NUMC = 12 ;
    
                   -- set the value of column NUMC to 12.
    
    if( COLA mat /XXX/ ){ COLA .= 'YYY' ; }
    
                   -- If column COLA contains the pattern 'XXX' then add the
                      literal 'YYY' to the end.
    
    COLA .= 'YYY' if COLA =~ /XXX/ ;
    
                   -- (same as above).
    
    if( COLA eq 'ABC' || COLA eq 'BCD' ){ COLA = 'XXX' ; }
    
                   -- If column COLA equals 'ABC' or 'BCD' set the value of
                      COLA to 'XXX'.
    
  
</PRE>
</CODE></BLOCKQUOTE>
<P>
<HR>
<A HREF="NoSQL-10.html">Previous</A>
<A HREF="NoSQL-12.html">Next</A>
<A HREF="NoSQL.html#toc11">Contents</A>
</BODY>
</HTML>