Sponsored Content
Top Forums UNIX for Dummies Questions & Answers A perfect number shell program Post 302359690 by Scott on Wednesday 7th of October 2009 07:14:52 AM
Old 10-07-2009
Code:

'expr $no / 2'

to
Code:
$(expr $no / 2)

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Write a shell program to find the sum of alternate digits in a given 5-digit number

Hi Can any one please post the answer for the above program.................. (4 Replies)
Discussion started by: banta
4 Replies

2. Shell Programming and Scripting

Prime Number Program (Fun)

Hi, I was just wondering if anyone has, or knows where to download a prime number finder program. I would like a fairly simple bash program, and also I would like one that could take advantage of multiple processors. I have 500 cores I can use, and would like to take advantage of them using a... (2 Replies)
Discussion started by: Kweekwom
2 Replies

3. Shell Programming and Scripting

extraction of perfect text from file.

Hi All, I have a file of the following format. <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="tomcat"/> <role rolename="role1"/> <role rolename="manager"/> <role rolename="admin"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user... (5 Replies)
Discussion started by: nua7
5 Replies

4. UNIX for Dummies Questions & Answers

Script producing error, Program to calculate maximum number

Hi folks, Here i have written a shell script to calculate a maximum number from 10 numbers entered on command line. max=0 echo Enter 10 numbers , one at a time for i in 1 2 3 4 5 6 7 8 9 10 do read n max=`expr $max + $n` if --- At this last step there is some problem, it gives error... (5 Replies)
Discussion started by: rits
5 Replies

5. AIX

I want the perfect user-interface

I've got an aix-box somewhere on the network and a PC on my desk. Nothing fancy so far. The PC is made dual-boot: - windowsXP with putty & winSCP or - slackware 13 with xfce4 installed. The aix-box runs DB2 v8.2 and I've installed db2top to monitor the database. db2top is a character... (0 Replies)
Discussion started by: dr_te_z
0 Replies

6. Shell Programming and Scripting

ksh program that finds the lowest number in a .txt file

i am having a problem finding the lowest number after punching in a bunch of numbers in the .txt file but its probably the way i have the code set up. help please! (4 Replies)
Discussion started by: tinsteer
4 Replies

7. Solaris

Resolving port number to program name

I was just checking to see if anyone had a script that would allow me to go from port number to program name. I tried to create my own script but it looks like it only works for IPv4 sockets and it looks like daemons such as sshd return as AF_INET6 (in pfiles) for some reason. I can fix my script... (0 Replies)
Discussion started by: thmnetwork
0 Replies

8. UNIX for Dummies Questions & Answers

Can you perfect my sed ?

I want to print only the lines that meet the criteria : "worde:" and "wordo;" I got this far: sed -n '/\(*\)\1e:\1o;/p;' But it doesn't quite work. Can someone please perfect it and tell me exactly how its a fixed version/what was wrong with mine? Thanks heaps, (1 Reply)
Discussion started by: maximus73
1 Replies

9. Shell Programming and Scripting

count number of entries perl program or Unix script

Hi I have a file with number of entries name 1 123 name 1 345 name 1 65346 name2 3243 name2 24234 name 2 234234 so on ......... how to count total number of entries for name 1 and name2...and so on Please guide. (1 Reply)
Discussion started by: manigrover
1 Replies

10. UNIX for Beginners Questions & Answers

How do I use grep to grab prime number output from my factor program?

I have a factor program that runs and outputs to stdout all the prime numbers that are specified in the given paramters, in this case 30000000-31000000. Command: factor/factor 30000000-31000000 Sample output: 30999979 = 30999979 30999980 = 2^2 5 11 140909 30999981 = 3 10333327... (6 Replies)
Discussion started by: steezuschrist96
6 Replies
Imager::Expr(3pm)					User Contributed Perl Documentation					 Imager::Expr(3pm)

NAME
Imager::Expr - implements expression parsing and compilation for the expression evaluation engine used by Imager::transform2() SYNOPSIS
my $code = Imager::Expr->new({rpnexpr=>$someexpr}) or die "Cannot compile $someexpr: ",Imager::Expr::error(); DESCRIPTION
This module is used internally by the Imager::transform2() function. You shouldn't have much need to use it directly, but you may want to extend it. To create a new Imager::Expr object, call: my %options; my $expr = Imager::Expr->new(\%options) or die Imager::Expr::error(); You will need to set an expression value and you may set any of the following: o constants A hashref defining extra constants for expression parsing. The names of the constants must be valid identifiers (/[^Wd]w*/) and the values must be valid numeric constants (that Perl recognizes in scalars). Imager::Expr may define it's own constants (currently just pi.) o variables A reference to an array of variable names. These are allocated numeric registers starting from register zero. By default you can define a "rpnexpr" key (which emulates RPN) or "expr" (an infix expression). It's also possible to write other expression parsers that will use other keys. Only one expression key should be defined. Instance methods The Imager::Expr::error() method is used to retrieve the error if the expression object cannot be created. Methods Imager::Expr provides only a few simple methods meant for external use: Imager::Expr->type_registered($keyword) Returns true if the given expression type is available. The parameter is the key supplied to the new() method. if (Imager::Expr->type_registered('expr')) { # use infix expressions } $expr->code() Returns the compiled code. $expr->nregs() Returns a reference to the array of numeric registers. $expr->cregs() Returns a reference to the array of color registers. $expr->dumpops() Returns a string with the generated VM "machine code". $expr->dumpcode() Returns a string with the disassembled VM "machine code". Creating a new parser I'll write this one day. Methods used by parsers: compile This is the main method you'll need to implement in a parser. See the existing parsers for a guide. It's supplied the following parameters: o $expr - the expression to be parsed o $options - the options hash supplied to transform2. Return an array ref of array refs containing opcodes and operands. @vars = $self->_variables() A list (not a reference) of the input variables. This should be used to allocate as many registers as there are variable as input registers. $self->error($message) Set the return value of Imager::Expr::error() @ops = $self->stack_to_reg(@stack_ops) Converts marginally parsed RPN to register code. assemble() Called to convert op codes into byte code. numre() Returns a regular expression that matches floating point numbers. optimize() Optimizes the assembly code, including attempting common subexpression elimination and strength reducing division by a constant into multiplication by a constant. register_type() Called by a new expression parser implementation to register itself, call as: YourClassName->register_type('type code'); where type code is the parameter that will accept the expression. Future compatibility Try to avoid doing your own optimization beyond literal folding - if we add some sort of jump, the existing optimizer will need to be rewritten, and any optimization you perform may well be broken too (well, your code generation will probably be broken anyway <sigh>). perl v5.14.2 2011-06-06 Imager::Expr(3pm)
All times are GMT -4. The time now is 07:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy