Sponsored Content
Full Discussion: perl issue ..
Top Forums Shell Programming and Scripting perl issue .. Post 302235951 by KevinADC on Saturday 13th of September 2008 11:22:10 PM
Old 09-14-2008
You can use a look up hash that points to subrotuines depending on the operator, an short example:

Code:
%com = (
   and => \&and,
);	

$one{val1} = 9;
$one{cond} = 'and';
$one{val2} = 13;
$val = 10;

if ($com{$one{'cond'}}->($val,$one{'val1'},$one{'val2'})) {
   print "true";
}

sub and {
   my ($v0,$v1,$v2) = @_;
   return(1) if ($v0 >= $v1 && $v0 <= $v2);
   return(0);
}

Note that '=>' is not a comparison operator, it is the comma operator.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

issue with if loop in perl

Hi I have a log file, I am having problem with "if else" loop in my perl script which does, find a string in that file ,If that string is found append to success.txt else append it to failed.txt. problem is: else part of loop it is not working I am adding problem part of the script. ... (4 Replies)
Discussion started by: amitrajvarma
4 Replies

2. Shell Programming and Scripting

Perl Script Issue - Please Help * Thanks!!!

Please help me with my script please. I am trying to do the following: 1. Read files for the current directory 2. Open and read from nbe files files only 3. Read only the lines with the results pattern 4. Split the line and print 3rd field Please indicate what line I need to modify. ... (8 Replies)
Discussion started by: jroberson
8 Replies

3. Shell Programming and Scripting

Perl Issue

Hi, I got this script from the web, this generates an LDAP report in CSV format. #!/usr/bin/perl # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar&064;zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for... (23 Replies)
Discussion started by: raj001
23 Replies

4. Shell Programming and Scripting

Perl issue - please help!

Hello. I've been writing some code in Perl to read in strings from html files and have been having issues. In the html file, each "paragraph" is a certain file on the website. I need to find every one of the files that is a certain type, in this case, having green color....therefore... (7 Replies)
Discussion started by: akreibich07
7 Replies

5. Shell Programming and Scripting

wc -l command issue with perl

Hi Team, the Following program execute with out error but the out is not save with create2.txt. kindly help me!!! print "Enter your Number \n"; my $name = <STDIN>; if ($name =="*91111*") { @dirlist1 = `wc -l $name > create2.txt`; } else {print "do not match";} (3 Replies)
Discussion started by: adaleru
3 Replies

6. Shell Programming and Scripting

perl command issue

Hi, Please could someone advise on a perl command : export ENVPROP="$HOME/cfg/environment.properties.template" export LM_LICENSE=`awk -F= '!/^#/ && /LM_LICENSE/{print $2}' environment.properties` echo $LM_LICENSE $DATA_FILE/licenses/sample.demo.lic perl -i -npe... (1 Reply)
Discussion started by: venhart
1 Replies

7. Shell Programming and Scripting

PERL - issue with OPEN

Hi, I have a menu script written in PERL which calls some shell scripts and displays the return. I'm having a problem with OPEN. A section of the code is below: `./scriptlist.ksh 1`; open OUTPUT, "</home/$SCRIPTUSER/output"; { local $/ = undef; $_ =... (2 Replies)
Discussion started by: chris01010
2 Replies

8. Shell Programming and Scripting

Perl format issue

Input : day :15 and count -100 printf ("%6.6ld %10.10s %s\n",day,count) any idea what would be the format it will be. (3 Replies)
Discussion started by: ramkumar15
3 Replies

9. Shell Programming and Scripting

Out of memory issue in perl

I am getting a out of memory issue while executing the perl program. Per version : /opt/acc_perl/lib/site_perl/5.14.2 Read in 54973 total records Read in 54973 table records from table. Out of memory! so the job get failed due to out of memory. need to get rid of the out of memory... (3 Replies)
Discussion started by: ramkumar15
3 Replies

10. Programming

Perl - EMail issue - NEED Help

I have a perl that is sending emails in a bad format: "begin 644 Included.doc M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BH*4U5#0T534T953"!-1$XG<R!F;W(@07)C:&EV92!022`M M($-A;F-E;`HJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ... (1 Reply)
Discussion started by: mrn6430
1 Replies
UDM_LOAD_ISPELL_DATA(3) 						 1						   UDM_LOAD_ISPELL_DATA(3)

udm_load_ispell_data - Load ispell data

SYNOPSIS
bool udm_load_ispell_data (resource $agent, int $var, string $val1, string $val2, int $flag) DESCRIPTION
udm_load_ispell_data(3) loads ispell data. After using this function to free memory allocated for ispell data, please use udm_free_ispell_data(3), even if you use UDM_ISPELL_TYPE_SERVER mode. PARAMETERS
o $agent - A link to Agent, received after call to udm_alloc_agent(3). o $var - Indicates the source for ispell data. May have the following values: o UDM_ISPELL_TYPE_DB - indicates that ispell data should be loaded from SQL. In this case, parameters $val1 and $val2 are ignored and should be left blank. $flag should be equal to 1. Note $flag indicates that after loading ispell data from defined source it should be sorted (it is necessary for correct functioning of ispell). In case of loading ispell data from files there may be several calls to udm_load_ispell_data(3), and there is no sense to sort data after every call, but only after the last one. Since in db mode all the data is loaded by one call, this parameter should have the value 1. In this mode in case of error, e.g. if ispell tables are absent, the function will return FALSE and code and error message will be accessible through udm_error(3) and udm_errno(3). o UDM_ISPELL_TYPE_AFFIX - indicates that ispell data should be loaded from file and initiates loading affixes file. In this case $val1 defines double letter language code for which affixes are loaded, and $val2 - file path. Please note, that if a relative path entered, the module looks for the file not in UDM_CONF_DIR, but in relation to current path, i.e. to the path where the script is executed. In case of error in this mode, e.g. if file is absent, the function will return FALSE, and an error message will be displayed. Error message text cannot be accessed through udm_error(3) and udm_errno(3), since those functions can only return messages associated with SQL. Please, see $flag parameter description in UDM_ISPELL_TYPE_DB. Example #1 udm_load_ispell_data(3) example <?php if ((! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'en', '/opt/ispell/en.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'ru', '/opt/ispell/ru.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'en', '/opt/ispell/en.dict', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'ru', '/opt/ispell/ru.dict', 1))) { exit; } ?> Note $flag is equal to 1 only in the last call. o UDM_ISPELL_TYPE_SPELL - indicates that ispell data should be loaded from file and initiates loading of ispell dictionary file. In this case $val1 defines double letter language code for which affixes are loaded, and $val2 - file path. Please note, that if a relative path entered, the module looks for the file not in UDM_CONF_DIR, but in relation to current path, i.e. to the path where the script is executed. In case of error in this mode, e.g. if file is absent, the function will return FALSE, and an error message will be displayed. Error message text cannot be accessed through udm_error(3) and udm_errno(3), since those functions can only return messages associated with SQL. Please, see $flag parameter description in UDM_ISPELL_TYPE_DB. <?php if ((! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'en', '/opt/ispell/en.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'ru', '/opt/ispell/ru.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'en', '/opt/ispell/en.dict', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'ru', '/opt/ispell/ru.dict', 1))) { exit; } ?> Note $flag is equal to 1 only in the last call. o UDM_ISPELL_TYPE_SERVER - enables spell server support. $val1 parameter indicates address of the host running spell server. $val2 ` is not used yet, but in future releases it is going to indicate number of port used by spell server. $flag parame- ter in this case is not needed since ispell data is stored on spellserver already sorted. Spelld server reads spell-data from a separate configuration file ( /usr/local/mnogosearch/etc/spelld.conf by default), sorts it and stores in memory. With clients server communicates in two ways: to indexer all the data is transferred (so that indexer starts faster), from search.cgi server receives word to normalize and then passes over to client (search.cgi) list of normalized word forms. This allows fastest, compared to db and text modes processing of search queries (by omitting loading and sorting all the spell data). udm_load_ispell_data(3) function in UDM_ISPELL_TYPE_SERVER mode does not actually load ispell data, but only defines server address. In fact, server is automatically used by udm_find(3) function when performing search. In case of errors, e.g. if spellserver is not running or invalid host indicated, there are no messages returned and ispell conversion does not work. Note This function is available in mnoGoSearch 3.1.12 or later. Example: <?php if (!udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SERVER, '', '', 1)) { echo "Error loading ispell data from server<br /> "; exit; } ?> The fastest mode is UDM_ISPELL_TYPE_SERVER. UDM_ISPELL_TYPE_TEXT is slower and UDM_ISPELL_TYPE_DB is the slowest. The above pat- tern is TRUE for mnoGoSearch 3.1.10 - 3.1.11. It is planned to speed up DB mode in future versions and it is going to be faster than TEXT mode. o $val1 - o $val2 - o $flag - RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #2 udm_load_ispell_data(3) example <?php if (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_DB, '', '', 1)) { printf("Error #%d: '%s' ", udm_errno($udm), udm_error($udm)); exit; } ?> PHP Documentation Group UDM_LOAD_ISPELL_DATA(3)
All times are GMT -4. The time now is 03:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy