Tie::Array::Sorted(3pm) User Contributed Perl Documentation Tie::Array::Sorted(3pm)NAME
Tie::Array::Sorted - An array which is kept sorted
SYNOPSIS
use Tie::Array::Sorted;
tie @a, "Tie::Array::Sorted", sub { $_[0] <=> $_[1] };
push @a, 10, 4, 7, 3, 4;
print "@a"; # "3 4 4 7 10"
DESCRIPTION
This presents an ordinary array, but is kept sorted. All pushes and unshifts cause the elements in question to be inserted in the appropri-
ate location to maintain order.
Direct stores ("$a[10] = "wibble"") effectively splice out the original value and insert the new element. It's not clear why you'd want to
use direct stores like that, but this module does the right thing if you do.
If you don't like the ordinary lexical comparator, you can provide your own; it should compare the two elements it is given. For instance,
a numeric comparator would look like this:
tie @a, "Tie::Array::Sorted", sub { $_[0] <=> $_[1] }
Whereas to compare a list of files by their sizes, you'd so something like:
tie @a, "Tie::Array::Sorted", sub { -s $_[0] <=> -s $_[1] }
LAZY SORTING
If you do more stores than fetches, you may find Tie::Array::Sorted::Lazy more efficient.
AUTHOR
Original author: Simon Cozens
Current maintainer: Tony Bowden
BUGS and QUERIES
Please direct all correspondence regarding this module to: bug-Tie-Array-Sorted@rt.cpan.org
This module was originall written as part of the Plucene project. However, as Plucene no longer uses this, it is effectively unmaintained.
COPYRIGHT AND LICENSE
Copyright (C) 2003-2006 Simon Cozens and Tony Bowden.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License; either version 2 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
perl v5.8.8 2004-10-10 Tie::Array::Sorted(3pm)
Check Out this Related Man Page
Tie::ToObject(3pm) User Contributed Perl Documentation Tie::ToObject(3pm)NAME
Tie::ToObject - Tie to an existing object.
SYNOPSIS
use Tie::ToObject;
my $stolen = tied(%something);
tie %something_else, 'Tie::ToObject', $stolen;
DESCRIPTION
While "tie" in perldoc allows tying to an arbitrary object, the class in question must support this in it's implementation of "TIEHASH",
"TIEARRAY" or whatever.
This class provides a very tie constructor that simply returns the object it was given as it's first argument.
This way side effects of calling "$object->TIEHASH" are avoided.
This is used in Data::Visitor in order to tie a variable to an already existing object. This is also useful for cloning, when you want to
clone the internal state object instead of going through the tie interface for that variable.
VERSION CONTROL
This module is maintained using Darcs. You can get the latest version from <http://nothingmuch.woobling.org/code>, and use "darcs send" to
commit changes.
AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
COPYRIGHT
Copyright (c) 2008 Yuval Kogman. 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.12.3 2008-01-17 Tie::ToObject(3pm)
I have a shell script (Solaris v8 ksh) loading an array from a flat file. An exaple of that flat file is below. It contains white-spaces, and carrage returns. When I try to load the first line as a variable, it (the variable) shows up as the first field not the first line. How do you arrange an... (9 Replies)
Array's example :) Hi all,
Since Iam learning the usage of Unix scripting, can any one provide some array examples (Simple to complex)?
With Regards,
Love (Jennifer) (5 Replies)
Hi all,
I have a question does anyone know if it is possible to push or pop an array in the ksh environment? Could anyone give me a hint, because I am trying to merge 2 server files together and there are some names in the server is not proper anymore.
Thank you in advance. (4 Replies)
Hi All
I am simulating a problem in the production where i faced a situation.
Please find the following example program which i simulated.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char str1; (3 Replies)
Hi there all,
I am having a question.
Is it posible to compare elements of 2 different arrays?
For example I got
Array 1 | Array 2
123_abc | 123_bcd
123_bcd | 234_bcd
234_abc | 567_abc
234_bcd | 123_abc
than the match is
123_abc & 234_bcd and non of the others.
So... (3 Replies)
Hi,
In a kshell , i need to compare the results of two array .
each Non-match value should copy to a new array.
For example:
==========
Array one contain the following values:
A
B
C
Array two contain the following values:
C
F
A
E
After comparing this arrays , a new array should... (4 Replies)
Hi.
for the following line:
Var1=${Array}
now Array has text as "{hello there}"
how do I remove the {} brackets before assigning the string to Var1?
Thanks. (3 Replies)
Hi,
i have to make a command in unix system which make a sorted list by cpu time (not %cpu ). If the application exists more than a time I would like to keep only one copy.
Could you help me please ???
P.s : I am trying --> ps aux --sort -%cpu | uniq
but I understand that is wrong (5 Replies)
Hello,
Question is related to Perl:
I need to search few of the files from the array of file names.
And after grepping the file names from an array I need to link these files to original location. The original location in this case is ref_path as input from the user.
##$ref_path is... (3 Replies)
I am new in perl ....
I defined Array in Perl which contain values as below:
Array name: @TEST
sample values : when I print Array: print " @test \n";
<title>0008857661</title>
<title>0009841171</title>
<title>0010161261</title>
<title>0010230023</title>
I want to get only these... (7 Replies)
$ cc Array.c
Array.c: In function ‘main’:
Array.c:23: warning: passing argument 1 of ‘scanf’ makes po
Array.c:25: error: expected expression before ‘return’
Array.c:29: error: expected expression before ‘return’
Array.c: At top level:
Array.c:44: error: expected ‘)’ before ‘&’ token... (8 Replies)
Array A contains lines of numbers from files. Array B contains number of fields for each line of each file.
I want to run on array A. To do that I need to know the number of fields for each file in array A (because each line doesn't have the same NF).
The NF is in array B, problem is: I don't... (6 Replies)
Hi guys
Let me at first describe the whole thing that I'm trying to do. Lets say I have 100 files like the following one.
Ow 1230 16.000000 -0.834000 16.083957
1.751652398 -17.20094528 -4.450623277
Hw 1231 ... (6 Replies)
Hi,
I am trying to do something similar to the for loop example from KSH For Loop Array: Iterate Through Array Values
$: cat y.ksh
#!/bin/ksh
# set array called nameservers
set -A nameservers 192.168.1.1 192.168.1.5 202.54.1.5
# print all name servers
for i in ${nameservers}
do
... (3 Replies)