There is a couple of ways to tackle the problem. Keep in mind when you pass arguments to a function they all become one big list. So either you pass the strings as the first arguments and the array last:
or you pass a reference to the array (it can be anywhere in the argument list, I place it first here only as an example):
Passing a array to a function, a basic feature in modern language, seems to be only possible in KSH. Not in BASH. Depite all my efforts I couldn't come to a solution. See the following examples:
It works perfectly in KSH:
#!/usr/bin/ksh
function print_array {
# assign array by indirect... (3 Replies)
Hi ,
I have three funcions f1, f2 and f3 .
f1 calls f2 and f2 calls f3 .
I have a global variable "period" which i want to pass to f3 .
Can i pass the variable directly in the definition of f3 ?
Pls help .
sars (4 Replies)
Hi there,
I am trying to call a shell script from a Perl script. here is the code:
@args = ("sh", "someshellprg.sh", "a file handler", "an array");
system(@args) == 0
or die "system @args failed: $?";
in the shell program, I examine if the arguments exits using:
if
then echo... (5 Replies)
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)
Hi All,
I am trying to pass an argument called "Pricelist" to a Perl function, then the function will open and print out the contents of the file named "Pricelist". But i can't seem to do it using my below code. Can any expert give some advice?
#!/usr/local/bin/perl
$DATABASE =... (1 Reply)
Hi,
I'm trying to write a function that reassigns an array to
another local array but the method used in reassigning
the array reformats the contents of the array which is
what I am trying to prevent.
The method used to load a file into an array works as
expected and the entire array is... (4 Replies)
Hi.
I have a problem with passing two dimensional array to a function.
First, let me show my code to explain what i am going to do:
I have function:void initialize_board(char board);which is supposed to modify content of passed array. I have read here: Question 6.18 how such arrays should be... (3 Replies)
this is my code to try and prinnt out a deck of cards. the print function worked when used inside main without being a function but now i cant get it to work as a function probably since i dont know how to pass a struct array in c. I gave it a shot but i keep getting an assortment of errors. The... (0 Replies)
my $sysdate = strftime('%Y-%m-%d', localtime );
biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals)
In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
Hello All,
I would like to ask help from you on how to pass variable value from a function that has been called inside the function. I have created below and
put the variables in " ". Is there another way I can do this? Thank you in advance.
readtasklist() {
while read -r mod ver... (1 Reply)
Discussion started by: aderamos12
1 Replies
LEARN ABOUT DEBIAN
prima::tie
Prima::Tie(3) User Contributed Perl Documentation Prima::Tie(3)NAME
Prima::Tie - tie widget properties to scalars or arrays.
DESCRIPTION
Prima::Tie contains two abstract classes, "Prima::Tie::Array" and "Prima::Tie::Scalar", which tie an array or a scalar to a widget's
arbitrary array or scalar property. Also, it contains classes "Prima::Tie::items", "Prima::Tie::text", and "Prima::Tie::value", which tie
a variable to a widget's items, text, and value property respectively.
SYNOPSIS
use Prima::Tie;
tie @items, 'Prima::Tie::items', $widget;
tie @some_property, 'Prima::Tie::Array', $widget, 'some_property';
tie $text, 'Prima::Tie::text', $widget;
tie $some_property, 'Prima::Tie::Scalar', $widget, 'some_property';
USAGE
These classes provide immediate access to a widget's array and scalar property, in particular to popular properties as items and text. It
is considerably simpler to say
splice(@items,3,1,'new item');
than to say
my @i = @{$widget->items};
splice(@i,3,1,'new item');
$widget->items(@i);
You can work directly with the text or items rather than at a remove. Furthermore, if the only reason you keep an object around after
creation is to access its text or items, you no no longer need to do so:
tie @some_array, 'Prima::Tie::items', Prima::ListBox->create(@args);
As opposed to:
my $widget = Prima::ListBox->create(@args);
tie @some_array, 'Prima::Tie::items', $widget;
"Prima::Tie::items" requires "::items" property to be available on the widget. Also, it takes advantage of additional "get_items",
"add_items", and the like if available.
Prima::Tie::items
The class is applicable to "Prima::ListViewer", "Prima::ListBox", "Prima::Header", and their descendants, and in limited fashion to
"Prima::OutlineViewer" and its descendants "Prima::StringOutline" and "Prima::Outline".
Prima::Tie::text
The class is applicable to any widget.
Prima::Tie::value
The class is applicable to "Prima::GroupBox", "Prima::ColorDialog", "Prima::SpinEdit", "Prima::Gauge", "Prima::Slider",
"Prima::CircularSlider", and "Prima::ScrollBar".
COPYRIGHT
Copyright 2004 Teo Sankaro
You may redistribute and/or modify this module under the same terms as Perl itself. (Although a credit would be nice.)
AUTHORS
Teo Sankaro, <teo_sankaro@hotmail.com>. Dmitry Karasik, <dmitry@karasik.eu.org>.
perl v5.14.2 2009-02-24 Prima::Tie(3)