Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How To Pass an Array Variable Post 302232429 by Ikon on Thursday 4th of September 2008 12:05:22 PM
Old 09-04-2008
Code:
declare -a ary
ary=($3)
echo $1 $2 ${ary[0]} ${ary[1]} ${ary[2]}

Code:
# sh script.sh why is "this so hard"
why is this so hard

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can we pass array with call by value in function

I want to pass an array in my function, And my function will be changing the elements of the array in the fuction, but it should not affect the values in my array variable of main function (1 Reply)
Discussion started by: ranjithpr
1 Replies

2. Shell Programming and Scripting

How to pass ksh array to oracle

Hi all.. Does anyone know have an example of passing the contents of a ksharray to oracle? basically I am looking to loop through the contents of a file and store each line into a bash ksh. Once i have this I can then pass the array into an oracle procedure that accepts an array as an... (1 Reply)
Discussion started by: kiranlalka
1 Replies

3. Programming

[ C ] multidemensional array pass to functions

Please excuse my ineptitude for a bit as I've been spoiled for the past few months with only writing perl code instead of C. So ok, I've been thinking about some code to change the crc32 values that are held within central directory headers of zip files. Because I'm lazy I decided to just... (3 Replies)
Discussion started by: VRoemer
3 Replies

4. UNIX for Dummies Questions & Answers

How to pass array as an arguement ?

Hi experts, I am here again with another Issue. I need to pass the array as parameter / argument to another script. I tried it as follows . ( I got this idea from the link ) $ cat test1.sh #! /usr/bin/ksh set -a arr1 echo "...In Test1...." arr1="APPS_DEV" arr1="TEST_DEV" echo... (16 Replies)
Discussion started by: rajavu
16 Replies

5. Shell Programming and Scripting

How to pass an array as arg to a script..

Hi, Please guide to pass an array as a arg to a script... for example, I have a script small.sh to find the small no of given arg as below... #! /bin/sh # this script is for finding the small number set -A arr_no_updates small=$1 i=1 for arr in $@ do if (3 Replies)
Discussion started by: little_wonder
3 Replies

6. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

7. Shell Programming and Scripting

Pass awk array variable to shell

Hi, all suppose I have following myfile (delimited by tab) aa bb cc dd ee ffand I have following awk command: awk 'BEGIN{FS="\t"}{AwkArrayVar_1=$1;AwkArrayVar_2=$2};END{for(i=0; i<NR; i++) print i, AwkArrayVar_1, AwkArrayVar_2,}' myfileMy question is: how can I assign the awk array... (7 Replies)
Discussion started by: littlewenwen
7 Replies

8. UNIX for Dummies Questions & Answers

Pass array to shell and print

How do i pass an array from test4.sh to a function in another shell script test5.sh, basically i am sourcing the test5.sh in test4.sh and printing the contents, but not working below are my trial scripts, please help, thank you. #!/bin/bash # /usr/local/dw/archive/test5.sh print_array() {... (5 Replies)
Discussion started by: Ariean
5 Replies

9. Shell Programming and Scripting

Pass array to a function and display the array

Hi All I have multiple arrays like below. set -A val1 1 2 4 5 set -A val2 a b c d . . . Now i would like to pass the individual arrays one by one to a function and display/ do some action. Note : I am using ksh Can you please advise any solution... Thanks in advance. (7 Replies)
Discussion started by: Girish19
7 Replies

10. UNIX for Dummies Questions & Answers

How to pass first array value?

Hi, I am creating filesystem for block device, but I want to pass array value one by one acording to block device count. $tmp1 = block device count 3 $blockdevice = So I want to first pass sdb1 alone in loop, how to take only block device seprately from $blockdevice array. (1 Reply)
Discussion started by: stew
1 Replies
Math::Symbolic::Variable(3pm)				User Contributed Perl Documentation			     Math::Symbolic::Variable(3pm)

NAME
Math::Symbolic::Variable - Variable in symbolic calculations SYNOPSIS
use Math::Symbolic::Variable; my $var1 = Math::Symbolic::Variable->new('name'); $var1->value(5); my $var2 = Math::Symbolic::Variable->new('x', 2); my $var3 = Math::Symbolic::Variable->new( { name => 'variable', value => 1, } ); DESCRIPTION
This class implements variables for Math::Symbolic trees. The objects are overloaded in stringification context to return their names. EXPORT None by default. METHODS
Constructor new First argument is expected to be a hash reference of key-value pairs which will be used as object attributes. In particular, a variable is required to have a 'name'. Optional arguments include a 'value', and a 'signature'. The value expected for the signature key is a reference to an array of identifiers. Special case: First argument is not a hash reference. In this case, first argument is treated as variable name, second as value. This special case disallows cloning of objects (when used as object method). Returns a Math::Symbolic::Variable. Method value value() evaluates the Math::Symbolic tree to its numeric representation. value() without arguments requires that every variable in the tree contains a defined value attribute. Please note that this refers to every variable object, not just every named variable. value() with one argument sets the object's value if you're dealing with Variables or Constants. In case of operators, a call with one argument will assume that the argument is a hash reference. (see next paragraph) value() with named arguments (key/value pairs) associates variables in the tree with the value-arguments if the corresponging key matches the variable name. (Can one say this any more complicated?) Since version 0.132, an equivalent and valid syntax is to pass a single hash reference instead of a list. Example: $tree->value(x => 1, y => 2, z => 3, t => 0) assigns the value 1 to any occurrances of variables of the name "x", aso. If a variable in the tree has no value set (and no argument of value sets it temporarily), the call to value() returns undef. Method name Optional argument: sets the object's name. Returns the object's name. Method signature signature() returns a tree's signature. In the context of Math::Symbolic, signatures are the list of variables any given tree depends on. That means the tree "v*t+x" depends on the variables v, t, and x. Thus, applying signature() on the tree that would be parsed from above example yields the sorted list ('t', 'v', 'x'). Constants do not depend on any variables and therefore return the empty list. Obviously, operators' dependencies vary. Math::Symbolic::Variable objects, however, may have a slightly more involved signature. By convention, Math::Symbolic variables depend on themselves. That means their signature contains their own name. But they can also depend on various other variables because variables themselves can be viewed as placeholders for more compicated terms. For example in mechanics, the acceleration of a particle depends on its mass and the sum of all forces acting on it. So the variable 'acceleration' would have the signature ('acceleration', 'force1', 'force2',..., 'mass', 'time'). If you're just looking for a list of the names of all variables in the tree, you should use the explicit_signature() method instead. Method explicit_signature explicit_signature() returns a lexicographically sorted list of variable names in the tree. See also: signature(). Method set_signature set_signature expects any number of variable identifiers as arguments. It sets a variable's signature to this list of identifiers. Method to_string Returns a string representation of the variable. Method term_type Returns the type of the term. (T_VARIABLE) AUTHOR
Please send feedback, bug reports, and support requests to the Math::Symbolic support mailing list: math-symbolic-support at lists dot sourceforge dot net. Please consider letting us know how you use Math::Symbolic. Thank you. If you're interested in helping with the development or extending the module's functionality, please contact the developers' mailing list: math-symbolic-develop at lists dot sourceforge dot net. List of contributors: Steffen Mueller, symbolic-module at steffen-mueller dot net Stray Toaster, mwk at users dot sourceforge dot net Oliver Ebenhoeh SEE ALSO
New versions of this module can be found on http://steffen-mueller.net or CPAN. The module development takes place on Sourceforge at http://sourceforge.net/projects/math-symbolic/ Math::Symbolic perl v5.10.1 2011-01-01 Math::Symbolic::Variable(3pm)
All times are GMT -4. The time now is 07:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy