Mercurial > repos > deepakjadmin > mayatool3_test2
comparison docs/modules/txt/TextUtil.txt @ 0:4816e4a8ae95 draft default tip
Uploaded
author | deepakjadmin |
---|---|
date | Wed, 20 Jan 2016 09:23:18 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4816e4a8ae95 |
---|---|
1 NAME | |
2 TextUtil | |
3 | |
4 SYNOPSIS | |
5 use TextUtil; | |
6 | |
7 use TextUtil qw(:all); | |
8 | |
9 DESCRIPTION | |
10 TextUtil module provides the following functions: | |
11 | |
12 AddNumberSuffix, ContainsWhiteSpaces, GetTextFileDataByNonUniqueKey, | |
13 GetTextFileDataByUniqueKey, GetTextLine, HashCode, IsEmpty, IsFloat, | |
14 IsInteger, IsNotEmpty, IsNumberPowerOfNumber, IsNumerical, | |
15 IsPositiveInteger, JoinWords, QuoteAWord, | |
16 RemoveLeadingAndTrailingWhiteSpaces, RemoveLeadingWhiteSpaces, | |
17 RemoveTrailingWhiteSpaces, SplitWords, WrapText | |
18 | |
19 FUNCTIONS | |
20 AddNumberSuffix | |
21 $NumberWithSuffix = AddNumberSuffix($IntegerValue); | |
22 | |
23 Returns number with appropriate suffix: 0, 1st, 2nd, 3rd, 4th, and | |
24 so on. | |
25 | |
26 ContainsWhiteSpaces | |
27 $Status = ContainsWhiteSpaces($TheString); | |
28 | |
29 Returns 1 or 0 based on whether the string contains any white | |
30 spaces. | |
31 | |
32 GetTextLine | |
33 $Line = GetTextLine(\*TEXTFILE); | |
34 | |
35 Reads next line from an already opened text file, takes out any | |
36 carriage return, and returns it as a string. NULL is returned for | |
37 EOF. | |
38 | |
39 GetTextFileDataByNonUniqueKey | |
40 GetTextFileDataByNonUniqueKey($TextDataFile, $TextDataMapRef, | |
41 $DataKeyColNum, $InDelim); | |
42 | |
43 Load data from a text file into the specified hash reference using a | |
44 specific column for non-unique data key values. | |
45 | |
46 The lines starting with # are treated as comments and ignored. First | |
47 line not starting with # must contain column labels and the number | |
48 of columns in all other data rows must match the number of column | |
49 labels. | |
50 | |
51 The first column is assumed to contain data key value by default; | |
52 all other columns contain data as indicated in their column labels. | |
53 | |
54 In order to avoid dependence of data access on the specified column | |
55 labels, the column data is loaded into hash with Column<Num> hash | |
56 keys, where column number start from 1. The data key column is not | |
57 available as Colnum<Num> hash key; | |
58 | |
59 The format of the data structure loaded into a specified hash | |
60 reference is: | |
61 | |
62 @{$TextDataMapRef->{DataKeys}} - Array of unique data keys | |
63 @{$TextDataMapRef->{ColLabels}} - Array of column labels | |
64 @{$TextDataMapRef->{DataColIDs}} - Array of data column IDs | |
65 $TextDataMapRef->{NumOfCols} - Number of columns | |
66 %{$TextDataMapRef->{DataKey}} - Hash keys pair: <DataKey, DataKey> | |
67 @{$TextDataMapRef->{DataCol<Num>}} - Hash keys pair with data as an array: | |
68 <DataCol<Num>, DataKey> | |
69 | |
70 GetTextFileDataByUniqueKey | |
71 GetTextFileDataByUniqueKey($TextDataFile, $TextDataMapRef, $DataKeyColNum, | |
72 $InDelim); | |
73 | |
74 Load data from a text file into the specified hash reference using a | |
75 a specific column for unique data key values. | |
76 | |
77 The lines starting with # are treated as comments and ignored. First | |
78 line not starting with # must contain column labels and the number | |
79 of columns in all other data rows must match the number of column | |
80 labels. | |
81 | |
82 The first column is assumed to contain data key value by default; | |
83 all other columns contain data as indicated in their column labels. | |
84 | |
85 In order to avoid dependence of data access on the specified column | |
86 labels, the column data is loaded into hash with Column<Num> hash | |
87 keys, where column number start from 1. The data key column is not | |
88 available as Colnum<Num> hash key; | |
89 | |
90 The format of the data structure loaded into a specified hash | |
91 reference is: | |
92 | |
93 @{$TextDataMapRef->{DataKeys}} - Array of unique data keys | |
94 @{$TextDataMapRef->{ColLabels}} - Array of column labels | |
95 @{$TextDataMapRef->{DataColIDs}} - Array of data column IDs | |
96 $TextDataMapRef->{NumOfCols} - Number of columns | |
97 %{$TextDataMapRef->{DataKey}} - Hash keys pair: <DataKey, DataKey> | |
98 %{$TextDataMapRef->{DataCol<Num>}} - Hash keys pair: <DataCol<Num>, DataKey> | |
99 | |
100 HashCode | |
101 $HashCode = HashCode($TheString); | |
102 | |
103 Returns a 32 bit integer hash code using One-at-a-time algorithm By | |
104 Bob Jenkins [Ref 38]. It's also implemented in Perl for internal | |
105 hash keys in hv.h include file. | |
106 | |
107 IsEmpty | |
108 $Status = IsEmpty($TheString); | |
109 | |
110 Returns 1 or 0 based on whether the string is empty. | |
111 | |
112 IsInteger | |
113 $Status = IsInteger($TheString); | |
114 | |
115 Returns 1 or 0 based on whether the string is a positive integer. | |
116 | |
117 IsPositiveInteger | |
118 $Status = IsPositiveInteger($TheString); | |
119 | |
120 Returns 1 or 0 based on whether the string is an integer. | |
121 | |
122 IsFloat | |
123 $Status = IsFloat($TheString); | |
124 | |
125 Returns 1 or 0 based on whether the string is a float. | |
126 | |
127 IsNotEmpty | |
128 $Status = IsNotEmpty($TheString); | |
129 | |
130 Returns 0 or 1 based on whether the string is empty. | |
131 | |
132 IsNumerical | |
133 $Status = IsNumerical($TheString); | |
134 | |
135 Returns 1 or 0 based on whether the string is a number. | |
136 | |
137 IsNumberPowerOfNumber | |
138 $Status = IsNumberPowerOfNumber($FirstNum, $SecondNum); | |
139 | |
140 Returns 1 or 0 based on whether the first number is a power of | |
141 second number. | |
142 | |
143 JoinWords | |
144 $JoinedWords = JoinWords($Words, $Delim, $Quote); | |
145 | |
146 Joins different words using delimiter and quote parameters, and | |
147 returns it as a string. | |
148 | |
149 QuoteAWord | |
150 $QuotedWord = QuoteAWord($Word, $Quote); | |
151 | |
152 Returns a quoted string based on *Quote* value. | |
153 | |
154 RemoveLeadingWhiteSpaces | |
155 $OutString = RemoveLeadingWhiteSpaces($InString); | |
156 | |
157 Returns a string without any leading and traling white spaces. | |
158 | |
159 RemoveTrailingWhiteSpaces | |
160 $OutString = RemoveTrailingWhiteSpaces($InString); | |
161 | |
162 Returns a string without any trailing white spaces. | |
163 | |
164 RemoveLeadingAndTrailingWhiteSpaces | |
165 $OutString = RemoveLeadingAndTrailingWhiteSpaces($InString); | |
166 | |
167 Returns a string without any leading and traling white spaces. | |
168 | |
169 SplitWords | |
170 @Words = SplitWords($Line, $Delimiter); | |
171 | |
172 Returns an array *Words* ontaining unquoted words generated after | |
173 spliting string value *Line* containing quoted or unquoted words. | |
174 | |
175 This function is used to split strings generated by JoinWords as | |
176 replacement for Perl's core module funtion | |
177 Text::ParseWords::quotewords() which dumps core on very long | |
178 strings. | |
179 | |
180 WrapText | |
181 $OutString = WrapText($InString, [$WrapLength, $WrapDelimiter]); | |
182 | |
183 Returns a wrapped string. By default, *WrapLenght* is *40* and | |
184 *WrapDelimiter* is Unix new line character. | |
185 | |
186 AUTHOR | |
187 Manish Sud <msud@san.rr.com> | |
188 | |
189 SEE ALSO | |
190 FileUtil.pm | |
191 | |
192 COPYRIGHT | |
193 Copyright (C) 2015 Manish Sud. All rights reserved. | |
194 | |
195 This file is part of MayaChemTools. | |
196 | |
197 MayaChemTools is free software; you can redistribute it and/or modify it | |
198 under the terms of the GNU Lesser General Public License as published by | |
199 the Free Software Foundation; either version 3 of the License, or (at | |
200 your option) any later version. | |
201 |