File: 10-basic.dat

package info (click to toggle)
libstring-interpolate-named-perl 1.06-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 148 kB
  • sloc: perl: 430; makefile: 2
file content (111 lines) | stat: -rw-r--r-- 2,242 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
# No substitutions
abcd			abcd

# Lone specials
ab%cd			ab%cd
ab{cd			ab{cd
ab%{cd			ab%{cd
ab}cd			ab}cd
ab\cd			ab\cd
ab|cd			ab|cd
ab\{cd			ab\{cd
ab\}cd			ab\}cd
ab\|cd			ab\|cd
ab\%cd			ab\%cd
ab\\cd			ab\\cd
ab\&cd			ab\&cd
abc\			abc\

# Variable
ab%{head}def		abyesdef
ab%{head}def%{head}xy	abyesdefyesxy
%{head}def		yesdef
%{h}def			Zdef

# Subtitute the value
X%{head}Y		XyesY
X%{head=yes}Y		XY
X%{head=no}Y		XY

# No value is empty string
X%{headx}Y		XY

# Subtitute the 'true' part
X%{head|}Y		XY
X%{head|foo}Y		XfooY
X%{head|fo\|o}Y		Xfo|oY

# %{} refers to the value of the key.
X%{head|This is %{}!}Y	XThis is yes!Y
X%{head=yes|This is %{}!}Y	XThis is yes!Y
X%{head=no|This is %{}!}Y	XY
X%{capo=1|%{} capo|%{} capoes}Y	X1 capoY
X%{capo=0|%{} capoes|%{} capo}Y	X1 capoY

# But only within a %{ ... }.
X%{}Y			X%{}Y

# Subtitute the 'false' part
X%{head=no|foo|bar}Y	XbarY
X%{hexd|foo|bar}Y	XbarY
X%{hexd=yes|foo|bar}Y	XbarY
X%{hexd=no|foo|bar}Y	XbarY
X%{hexd=|foo|bar}Y	XfooY
X%{hexd|foo}Y		XY
X|%{hexd|fo\|o}|Y	X||Y
X%{h|foo|bar}Y		XfooY
X%{h=Z|foo|bar}Y	XfooY

# Nested.
X%{head|x%{foo}z|bar}Y	XxzY
X%{hexd|x%{foo}z|bar}Y	XbarY
X%{head|x%{h|\\\|}z|bar}Y	Xx|zY
X%{head|x%{foo||\\\|}z|bar}Y	Xx|zY

# Note that %{} is the value of foo (inner), not head (outer)
X%{head|x%{foo|ab|f%{}g}z}Y	XxfgzY

# Recursive substitution.
%{subtitle}	CAPO 1

# Transpose.
%{key}		G

# Formatting
%{capo:%02d}	01
%{capo=1|%{capo:%02d}|no}	01
%{capo:%02d=01|yes%{}|no}	yes01
[%{capo:%6.2s}]	[     1]

# Case changers
%{title:uc}	HI THERE!
%{title:lc}	hi there!
%{title:ic}	Hi There!
%{title:lc:ic}	Hi There!
%{title:sc}	Hi There!
%{title:lc:sc}	Hi there!

# Formatting doesn't interfere with definedness
X%{1:%02d}Y	XY
X%{hexd:sc}Y	XY

# Padding
X%{key:lpad(0)}Y	XGY
X%{key:lpad(4)}Y	X   GY
X%{key:lpad(4,-)}Y	X---GY
X%{key:lpad(4,xy)}Y	XxyxGY
X%{head:lpad(2)}Y	XyesY
X%{head:lpad(3)}Y	XyesY
X%{key:rpad(4)}Y	XG   Y
X%{key:rpad(4,-)}Y	XG---Y
X%{key:rpad(4,xy)}Y	XGxyxY
X%{head:rpad(2)}Y	XyesY
X%{head:rpad(3)}Y	XyesY

# Replace
%{title:replace( ,_)}	Hi_There!
%{title:replace( ,,)}	Hi,There!
%{title:replace( ,,):replace(,, )}	Hi There!
%{title:replace( ,\:):replace(\:, )}	Hi There!
%{title:replace(!,)}	Hi There
%{title:replace(!,\})}	Hi There}