Mercurial > repos > deepakjadmin > mayatool3_test2
comparison docs/modules/html/TextUtil.html @ 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 <html> | |
| 2 <head> | |
| 3 <title>MayaChemTools:Documentation:TextUtil.pm</title> | |
| 4 <meta http-equiv="content-type" content="text/html;charset=utf-8"> | |
| 5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css"> | |
| 6 </head> | |
| 7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10"> | |
| 8 <br/> | |
| 9 <center> | |
| 10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a> | |
| 11 </center> | |
| 12 <br/> | |
| 13 <div class="DocNav"> | |
| 14 <table width="100%" border=0 cellpadding=0 cellspacing=2> | |
| 15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./StatisticsUtil.html" title="StatisticsUtil.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./TimeUtil.html" title="TimeUtil.html">Next</a></td><td width="34%" align="middle"><strong>TextUtil.pm</strong></td><td width="33%" align="right"><a href="././code/TextUtil.html" title="View source code">Code</a> | <a href="./../pdf/TextUtil.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/TextUtil.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/TextUtil.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/TextUtil.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr> | |
| 16 </table> | |
| 17 </div> | |
| 18 <p> | |
| 19 </p> | |
| 20 <h2>NAME</h2> | |
| 21 <p>TextUtil</p> | |
| 22 <p> | |
| 23 </p> | |
| 24 <h2>SYNOPSIS</h2> | |
| 25 <p>use TextUtil;</p> | |
| 26 <p>use TextUtil qw(:all);</p> | |
| 27 <p> | |
| 28 </p> | |
| 29 <h2>DESCRIPTION</h2> | |
| 30 <p><strong>TextUtil</strong> module provides the following functions:</p> | |
| 31 <p> <a href="#addnumbersuffix">AddNumberSuffix</a>, <a href="#containswhitespaces">ContainsWhiteSpaces</a>, <a href="#gettextfiledatabynonuniquekey">GetTextFileDataByNonUniqueKey</a> | |
| 32 , <a href="#gettextfiledatabyuniquekey">GetTextFileDataByUniqueKey</a>, <a href="#gettextline">GetTextLine</a>, <a href="#hashcode">HashCode</a>, <a href="#isempty">IsEmpty</a>, <a href="#isfloat">IsFloat</a>, <a href="#isinteger">IsInteger</a> | |
| 33 , <a href="#isnotempty">IsNotEmpty</a>, <a href="#isnumberpowerofnumber">IsNumberPowerOfNumber</a>, <a href="#isnumerical">IsNumerical</a>, <a href="#ispositiveinteger">IsPositiveInteger</a>, <a href="#joinwords">JoinWords</a> | |
| 34 , <a href="#quoteaword">QuoteAWord</a>, <a href="#removeleadingandtrailingwhitespaces">RemoveLeadingAndTrailingWhiteSpaces</a>, <a href="#removeleadingwhitespaces">RemoveLeadingWhiteSpaces</a> | |
| 35 , <a href="#removetrailingwhitespaces">RemoveTrailingWhiteSpaces</a>, <a href="#splitwords">SplitWords</a>, <a href="#wraptext">WrapText</a> | |
| 36 </p><p> | |
| 37 </p> | |
| 38 <h2>FUNCTIONS</h2> | |
| 39 <dl> | |
| 40 <dt><strong><a name="addnumbersuffix" class="item"><strong>AddNumberSuffix</strong></a></strong></dt> | |
| 41 <dd> | |
| 42 <div class="OptionsBox"> | |
| 43 $NumberWithSuffix = AddNumberSuffix($IntegerValue);</div> | |
| 44 <p>Returns number with appropriate suffix: 0, 1st, 2nd, 3rd, 4th, and so on.</p> | |
| 45 </dd> | |
| 46 <dt><strong><a name="containswhitespaces" class="item"><strong>ContainsWhiteSpaces</strong></a></strong></dt> | |
| 47 <dd> | |
| 48 <div class="OptionsBox"> | |
| 49 $Status = ContainsWhiteSpaces($TheString);</div> | |
| 50 <p>Returns 1 or 0 based on whether the string contains any white spaces.</p> | |
| 51 </dd> | |
| 52 <dt><strong><a name="gettextline" class="item"><strong>GetTextLine</strong></a></strong></dt> | |
| 53 <dd> | |
| 54 <div class="OptionsBox"> | |
| 55 $Line = GetTextLine(\*TEXTFILE);</div> | |
| 56 <p>Reads next line from an already opened text file, takes out any carriage return, | |
| 57 and returns it as a string. NULL is returned for EOF.</p> | |
| 58 </dd> | |
| 59 <dt><strong><a name="gettextfiledatabynonuniquekey" class="item"><strong>GetTextFileDataByNonUniqueKey</strong></a></strong></dt> | |
| 60 <dd> | |
| 61 <div class="OptionsBox"> | |
| 62 GetTextFileDataByNonUniqueKey($TextDataFile, $TextDataMapRef, | |
| 63 $DataKeyColNum, $InDelim);</div> | |
| 64 <p>Load data from a text file into the specified hash reference using a specific | |
| 65 column for non-unique data key values.</p> | |
| 66 <p>The lines starting with # are treated as comments and ignored. First line | |
| 67 not starting with # must contain column labels and the number of columns in | |
| 68 all other data rows must match the number of column labels.</p> | |
| 69 <p>The first column is assumed to contain data key value by default; all other columns | |
| 70 contain data as indicated in their column labels.</p> | |
| 71 <p>In order to avoid dependence of data access on the specified column labels, the | |
| 72 column data is loaded into hash with Column<Num> hash keys, where column number | |
| 73 start from 1. The data key column is not available as Colnum<Num> hash key;</p> | |
| 74 <p>The format of the data structure loaded into a specified hash reference is:</p> | |
| 75 <div class="OptionsBox"> | |
| 76 @{$TextDataMapRef->{DataKeys}} - Array of unique data keys | |
| 77 <br/> @{$TextDataMapRef->{ColLabels}} - Array of column labels | |
| 78 <br/> @{$TextDataMapRef->{DataColIDs}} - Array of data column IDs | |
| 79 <br/> $TextDataMapRef->{NumOfCols} - Number of columns | |
| 80 <br/> %{$TextDataMapRef->{DataKey}} - Hash keys pair: <DataKey, DataKey> | |
| 81 <br/> @{$TextDataMapRef->{DataCol<Num>}} - Hash keys pair with data as an array: | |
| 82 <DataCol<Num>, DataKey></div> | |
| 83 </dd> | |
| 84 <dt><strong><a name="gettextfiledatabyuniquekey" class="item"><strong>GetTextFileDataByUniqueKey</strong></a></strong></dt> | |
| 85 <dd> | |
| 86 <div class="OptionsBox"> | |
| 87 GetTextFileDataByUniqueKey($TextDataFile, $TextDataMapRef, $DataKeyColNum, | |
| 88 $InDelim);</div> | |
| 89 <p>Load data from a text file into the specified hash reference using a a specific | |
| 90 column for unique data key values.</p> | |
| 91 <p>The lines starting with # are treated as comments and ignored. First line | |
| 92 not starting with # must contain column labels and the number of columns in | |
| 93 all other data rows must match the number of column labels.</p> | |
| 94 <p>The first column is assumed to contain data key value by default; all other columns | |
| 95 contain data as indicated in their column labels.</p> | |
| 96 <p>In order to avoid dependence of data access on the specified column labels, the | |
| 97 column data is loaded into hash with Column<Num> hash keys, where column number | |
| 98 start from 1. The data key column is not available as Colnum<Num> hash key;</p> | |
| 99 <p>The format of the data structure loaded into a specified hash reference is:</p> | |
| 100 <div class="OptionsBox"> | |
| 101 @{$TextDataMapRef->{DataKeys}} - Array of unique data keys | |
| 102 <br/> @{$TextDataMapRef->{ColLabels}} - Array of column labels | |
| 103 <br/> @{$TextDataMapRef->{DataColIDs}} - Array of data column IDs | |
| 104 <br/> $TextDataMapRef->{NumOfCols} - Number of columns | |
| 105 <br/> %{$TextDataMapRef->{DataKey}} - Hash keys pair: <DataKey, DataKey> | |
| 106 <br/> %{$TextDataMapRef->{DataCol<Num>}} - Hash keys pair: <DataCol<Num>, DataKey></div> | |
| 107 </dd> | |
| 108 <dt><strong><a name="hashcode" class="item"><strong>HashCode</strong></a></strong></dt> | |
| 109 <dd> | |
| 110 <div class="OptionsBox"> | |
| 111 $HashCode = HashCode($TheString);</div> | |
| 112 <p>Returns a 32 bit integer hash code using One-at-a-time algorithm By Bob Jenkins [Ref 38]. | |
| 113 It's also implemented in Perl for internal hash keys in hv.h include file.</p> | |
| 114 </dd> | |
| 115 <dt><strong><a name="isempty" class="item"><strong>IsEmpty</strong></a></strong></dt> | |
| 116 <dd> | |
| 117 <div class="OptionsBox"> | |
| 118 $Status = IsEmpty($TheString);</div> | |
| 119 <p>Returns 1 or 0 based on whether the string is empty.</p> | |
| 120 </dd> | |
| 121 <dt><strong><a name="isinteger" class="item"><strong>IsInteger</strong></a></strong></dt> | |
| 122 <dd> | |
| 123 <div class="OptionsBox"> | |
| 124 $Status = IsInteger($TheString);</div> | |
| 125 <p>Returns 1 or 0 based on whether the string is a positive integer.</p> | |
| 126 </dd> | |
| 127 <dt><strong><a name="ispositiveinteger" class="item"><strong>IsPositiveInteger</strong></a></strong></dt> | |
| 128 <dd> | |
| 129 <div class="OptionsBox"> | |
| 130 $Status = IsPositiveInteger($TheString);</div> | |
| 131 <p>Returns 1 or 0 based on whether the string is an integer.</p> | |
| 132 </dd> | |
| 133 <dt><strong><a name="isfloat" class="item"><strong>IsFloat</strong></a></strong></dt> | |
| 134 <dd> | |
| 135 <div class="OptionsBox"> | |
| 136 $Status = IsFloat($TheString);</div> | |
| 137 <p>Returns 1 or 0 based on whether the string is a float.</p> | |
| 138 </dd> | |
| 139 <dt><strong><a name="isnotempty" class="item"><strong>IsNotEmpty</strong></a></strong></dt> | |
| 140 <dd> | |
| 141 <div class="OptionsBox"> | |
| 142 $Status = IsNotEmpty($TheString);</div> | |
| 143 <p>Returns 0 or 1 based on whether the string is empty.</p> | |
| 144 </dd> | |
| 145 <dt><strong><a name="isnumerical" class="item"><strong>IsNumerical</strong></a></strong></dt> | |
| 146 <dd> | |
| 147 <div class="OptionsBox"> | |
| 148 $Status = IsNumerical($TheString);</div> | |
| 149 <p>Returns 1 or 0 based on whether the string is a number.</p> | |
| 150 </dd> | |
| 151 <dt><strong><a name="isnumberpowerofnumber" class="item"><strong>IsNumberPowerOfNumber</strong></a></strong></dt> | |
| 152 <dd> | |
| 153 <div class="OptionsBox"> | |
| 154 $Status = IsNumberPowerOfNumber($FirstNum, $SecondNum);</div> | |
| 155 <p>Returns 1 or 0 based on whether the first number is a power of second number.</p> | |
| 156 </dd> | |
| 157 <dt><strong><a name="joinwords" class="item"><strong>JoinWords</strong></a></strong></dt> | |
| 158 <dd> | |
| 159 <div class="OptionsBox"> | |
| 160 $JoinedWords = JoinWords($Words, $Delim, $Quote);</div> | |
| 161 <p>Joins different words using delimiter and quote parameters, and returns it | |
| 162 as a string.</p> | |
| 163 </dd> | |
| 164 <dt><strong><a name="quoteaword" class="item"><strong>QuoteAWord</strong></a></strong></dt> | |
| 165 <dd> | |
| 166 <div class="OptionsBox"> | |
| 167 $QuotedWord = QuoteAWord($Word, $Quote);</div> | |
| 168 <p>Returns a quoted string based on <em>Quote</em> value.</p> | |
| 169 </dd> | |
| 170 <dt><strong><a name="removeleadingwhitespaces" class="item"><strong>RemoveLeadingWhiteSpaces</strong></a></strong></dt> | |
| 171 <dd> | |
| 172 <div class="OptionsBox"> | |
| 173 $OutString = RemoveLeadingWhiteSpaces($InString);</div> | |
| 174 <p>Returns a string without any leading and traling white spaces.</p> | |
| 175 </dd> | |
| 176 <dt><strong><a name="removetrailingwhitespaces" class="item"><strong>RemoveTrailingWhiteSpaces</strong></a></strong></dt> | |
| 177 <dd> | |
| 178 <div class="OptionsBox"> | |
| 179 $OutString = RemoveTrailingWhiteSpaces($InString);</div> | |
| 180 <p>Returns a string without any trailing white spaces.</p> | |
| 181 </dd> | |
| 182 <dt><strong><a name="removeleadingandtrailingwhitespaces" class="item"><strong>RemoveLeadingAndTrailingWhiteSpaces</strong></a></strong></dt> | |
| 183 <dd> | |
| 184 <div class="OptionsBox"> | |
| 185 $OutString = RemoveLeadingAndTrailingWhiteSpaces($InString);</div> | |
| 186 <p>Returns a string without any leading and traling white spaces.</p> | |
| 187 </dd> | |
| 188 <dt><strong><a name="splitwords" class="item"><strong>SplitWords</strong></a></strong></dt> | |
| 189 <dd> | |
| 190 <div class="OptionsBox"> | |
| 191 @Words = SplitWords($Line, $Delimiter);</div> | |
| 192 <p>Returns an array <em>Words</em> ontaining unquoted words generated after spliting | |
| 193 string value <em>Line</em> containing quoted or unquoted words.</p> | |
| 194 <p>This function is used to split strings generated by JoinWords as replacement | |
| 195 for Perl's core module funtion Text::ParseWords::quotewords() which dumps core | |
| 196 on very long strings.</p> | |
| 197 </dd> | |
| 198 <dt><strong><a name="wraptext" class="item"><strong>WrapText</strong></a></strong></dt> | |
| 199 <dd> | |
| 200 <div class="OptionsBox"> | |
| 201 $OutString = WrapText($InString, [$WrapLength, $WrapDelimiter]);</div> | |
| 202 <p>Returns a wrapped string. By default, <em>WrapLenght</em> is <em>40</em> and <em>WrapDelimiter</em> | |
| 203 is Unix new line character.</p> | |
| 204 </dd> | |
| 205 </dl> | |
| 206 <p> | |
| 207 </p> | |
| 208 <h2>AUTHOR</h2> | |
| 209 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p> | |
| 210 <p> | |
| 211 </p> | |
| 212 <h2>SEE ALSO</h2> | |
| 213 <p><a href="./FileUtil.html">FileUtil.pm</a> | |
| 214 </p> | |
| 215 <p> | |
| 216 </p> | |
| 217 <h2>COPYRIGHT</h2> | |
| 218 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p> | |
| 219 <p>This file is part of MayaChemTools.</p> | |
| 220 <p>MayaChemTools is free software; you can redistribute it and/or modify it under | |
| 221 the terms of the GNU Lesser General Public License as published by the Free | |
| 222 Software Foundation; either version 3 of the License, or (at your option) | |
| 223 any later version.</p> | |
| 224 <p> </p><p> </p><div class="DocNav"> | |
| 225 <table width="100%" border=0 cellpadding=0 cellspacing=2> | |
| 226 <tr align="left" valign="top"><td width="33%" align="left"><a href="./StatisticsUtil.html" title="StatisticsUtil.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./TimeUtil.html" title="TimeUtil.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>TextUtil.pm</strong></td></tr> | |
| 227 </table> | |
| 228 </div> | |
| 229 <br /> | |
| 230 <center> | |
| 231 <img src="../../images/h2o2.png"> | |
| 232 </center> | |
| 233 </body> | |
| 234 </html> |
