I am trying to reference a two dimensional array in a
subroutine and can't seem to figure this one out in Perl.
Does anybody know? Please enlighten me.
#!/usr/bin/perl -w
use constant DIM => 4;
sub Shift_elements_right{
my (@Input, @Output) = @_;
for ($i = 0 ; $i <= DIM ;... (5 Replies)
I am going to develop a address book using the shell scripting commands without sed, awk, .... I am thinking to apply the concept of 2 dimenstional array. Can I create a two dimensional array for the insertion/updation/deletion of record in unix. If yes then tell me plz or recommend me some... (1 Reply)
Hi.
I am reasonably new to awk, but have done quite a lot of unix scripting in the past. I have resolved the issues below with unix scripting but it runs like a dog. Moved to awk for speed and functionality but running up a big learning curve in a hurry, so hope there is some help here.
I... (6 Replies)
I am trying to implementing two dimensinal array in ksh script.Would you pls help me out.
I have a large size of file, File contains looks like
ID SID VLAUE1 VALUE2 TOTALVALUE
1 a1 01 02 03
1 b1 02 05 07 ... (2 Replies)
Hi All,
I'm writing a nagios check that will see if our ldap servers are in sync...
I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable
so...eg...let take the single array... (1 Reply)
Hello,
I'm experiencing a weird seg fault at run time when initializing a bi-dimensional array and initializing a class.
Please see below code and comments describing the error and the instances when it occurs and when it does not occur.
Compiled with g++ segf.cpp -o segf
output
On... (5 Replies)
I am writing matrix multiplication and trying to return a two dimensional array from a function but I keep getting errors. Can someone please help me?
here is my code (it is just the skeleton of my program):
void main ()
{
...
int *matmultiply (int, int, int, int , int , int )
...
}
... (4 Replies)
Hi Community,
Would love to get some quick help on below requirement.
I am trying to process mpstat output from multiple blades of my server
I would like to assign this the output to an array and then use it for post processing. How can I use a two dimensional array and assign these value
... (23 Replies)
I have an array of names. Each one of the name, has a number represented to it.
For example A has an ID 8, B has an ID 2.
What I am after is a for loop that when the array is in position 1, a particular variable is set to the value of position 1 in array 2
declare -a arr=("A" "B" "C"... (6 Replies)
Hi,
I have a 10*10 two dimensional array. How do I assign value to all it's 100 elements at once? I don't want to open two for loops and assign one by one.
Thanks,
Shuri (1 Reply)
Discussion started by: shurimano
1 Replies
LEARN ABOUT REDHAT
io::select
IO::Select(3pm) Perl Programmers Reference Guide IO::Select(3pm)NAME
IO::Select - OO interface to the select system call
SYNOPSIS
use IO::Select;
$s = IO::Select->new();
$s->add(*STDIN);
$s->add($some_handle);
@ready = $s->can_read($timeout);
@ready = IO::Select->new(@handles)->read(0);
DESCRIPTION
The "IO::Select" package implements an object approach to the system "select" function call. It allows the user to see what IO handles, see
IO::Handle, are ready for reading, writing or have an error condition pending.
CONSTRUCTOR
new ( [ HANDLES ] )
The constructor creates a new object and optionally initialises it with a set of handles.
METHODS
add ( HANDLES )
Add the list of handles to the "IO::Select" object. It is these values that will be returned when an event occurs. "IO::Select" keeps
these values in a cache which is indexed by the "fileno" of the handle, so if more than one handle with the same "fileno" is specified
then only the last one is cached.
Each handle can be an "IO::Handle" object, an integer or an array reference where the first element is an "IO::Handle" or an integer.
remove ( HANDLES )
Remove all the given handles from the object. This method also works by the "fileno" of the handles. So the exact handles that were
added need not be passed, just handles that have an equivalent "fileno"
exists ( HANDLE )
Returns a true value (actually the handle itself) if it is present. Returns undef otherwise.
handles
Return an array of all registered handles.
can_read ( [ TIMEOUT ] )
Return an array of handles that are ready for reading. "TIMEOUT" is the maximum amount of time to wait before returning an empty list,
in seconds, possibly fractional. If "TIMEOUT" is not given and any handles are registered then the call will block.
can_write ( [ TIMEOUT ] )
Same as "can_read" except check for handles that can be written to.
has_exception ( [ TIMEOUT ] )
Same as "can_read" except check for handles that have an exception condition, for example pending out-of-band data.
count ()
Returns the number of handles that the object will check for when one of the "can_" methods is called or the object is passed to the
"select" static method.
bits()
Return the bit string suitable as argument to the core select() call.
select ( READ, WRITE, ERROR [, TIMEOUT ] )
"select" is a static method, that is you call it with the package name like "new". "READ", "WRITE" and "ERROR" are either "undef" or
"IO::Select" objects. "TIMEOUT" is optional and has the same effect as for the core select call.
The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing
and have error conditions respectively. Upon error an empty array is returned.
EXAMPLE
Here is a short example which shows how "IO::Select" could be used to write a server which communicates with several sockets while also
listening for more connections on a listen socket
use IO::Select;
use IO::Socket;
$lsn = new IO::Socket::INET(Listen => 1, LocalPort => 8080);
$sel = new IO::Select( $lsn );
while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if($fh == $lsn) {
# Create a new socket
$new = $lsn->accept;
$sel->add($new);
}
else {
# Process socket
# Maybe we have finished with the socket
$sel->remove($fh);
$fh->close;
}
}
}
AUTHOR
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs to <perl5-porters@perl.org>.
COPYRIGHT
Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
perl v5.8.0 2002-06-01 IO::Select(3pm)