03-28-2012
compare two array
Hi firnds,
I am having two arrays
eg. @a=qw(1 2 3 4) and @b=qw(1 3 6 9)
Now, I want to compare two arrays on first index of both arrays and if they matched, it should output remaining indexes
Pseudo-code
if ($a[0] == $b[0])
{ print "remaining indexes";}
How can i do this using perl?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have an array "arrA" with the following contents:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
My data file "Files.dat" has the same contents:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
I have a script that compares... (0 Replies)
Discussion started by: orahi001
0 Replies
2. Shell Programming and Scripting
hi everyone -
i have a bash script that does, in broad terms, the following:
given a file containing a list of email accounts, for every account, do , then move on to the next account. pretty simple, and all that stuff works fine.
thing is, there's a very good change that any account... (2 Replies)
Discussion started by: fearboy
2 Replies
3. UNIX for Dummies Questions & Answers
# tail myprocesses.txt
178 processes at Tue Oct 21 14:33:01 IST 2008
16 MySQL processes at Tue Oct 21 14:33:01 IST 2008
175 processes at Tue Oct 21 14:36:01 IST 2008
60 MySQL processes at Tue Oct 21 14:36:01 IST 2008
192 processes at Tue Oct 21 14:39:01 IST 2008
64 MySQL processes at Tue Oct... (2 Replies)
Discussion started by: shantanuo
2 Replies
4. Shell Programming and Scripting
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)
Discussion started by: yoavbe
4 Replies
5. UNIX for Dummies Questions & Answers
Using the bash shell I am trying to read in 2 files. The first file (file1) is a list of names to search for in (file2). If a name in file1 is found in file2 I want the entire line in file2 to be printed to an output file. File1 consists of a single column of names. File2 consists of several... (2 Replies)
Discussion started by: lanna001
2 Replies
6. Shell Programming and Scripting
i have an array call ignore. it is set up
ignore=34th56
ignore=re45ty
ignore=rt45yu
.
.
ignore=rthg34
n is a variable. I have another variable that i read from a different file. It is $2 and it is working the way i expect. array ignore read and print correct values.
in the below if... (2 Replies)
Discussion started by: usustarr
2 Replies
7. Shell Programming and Scripting
Hi, I just wondering if I want to compare previous value to next value if it same count + 1 if not doesn't count how do we compare in Perl? Thank (2 Replies)
Discussion started by: guidely
2 Replies
8. Shell Programming and Scripting
ok, so here is the issue, I have 2 arrays.
I need to be able to create a loop that will find ${ARRAY1 in the text doc, and replace it with ${ARRAY2 then write the results. I already have that working. The problem is, I need it to do that same result across however many items are in the 2... (2 Replies)
Discussion started by: gentlefury
2 Replies
9. UNIX for Dummies Questions & Answers
Hi all,
Currently i am facing issue using if command to compare to array value.
can someone help me?
if }" -gt "${ZDATE_1}" ]
then
do
echo "red"
else
echo "green"
fi
done
i have checked array is giving values fine but there seems some issue with if command. (2 Replies)
Discussion started by: amyt1234
2 Replies
10. Shell Programming and Scripting
Hello,
i have a script that should compare between ${ARRAY}
that contains all fstab record like this :
>>echo ${ARRAY}
/ /boot
between all mountpoints in my df that is stord in ${ARRAY2}
>>echo ${ARRAY2}
/ /boot /dev/shm /var/spool/asterisk/monitor
now i have this loop:
for i in... (6 Replies)
Discussion started by: batchenr
6 Replies
LEARN ABOUT SUSE
tk::reindex
Reindex(3) perl/Tk Documentation Reindex(3)
NAME
Tk::Reindex - change the base index of Text-like widgets
SYNOPSIS
use Tk::ReindexedText;
$t1=$w->ReindexedText(-linestart => 2);
use Tk::ReindexedROText;
$t2=$w->ReindexedROText(-linestart => 0);
DESCRIPTION
Creates a new widget class based on Text-like widgets that can redefine the line number base (normally Text widgets start line numbers at
1), or possibly other manipulations on indexes.
STANDARD OPTIONS
The newly-defined widget takes all the same options as the base widget, which defaults to Text.
WIDGET-SPECIFIC OPTIONS
Name: lineStart
Class: LineStart
Switch: -linestart
Sets the line number of the first line in the Text widget. The default -toindexcmd and -fromindexcmd use this configuration option.
-item Name: toIndexCmd fromIndexCmd
-item Class: ToIndexCmd FromIndexCmd
-item Switch: -toindexcmd -fromindexcmd
These two options specify callbacks that are called with a list of indexes and are responsible for translating them to/from indexes
that the base Text widget can understand. The callback is passed the widget followed by a list of indexes, and should return a list of
translated indexes. -toindexcmd should translate from 'user' indexes to 'native' Text-compatible indexes, and -fromindexcmd should
translate from 'native' indexes to 'user' indexes.
The default callbacks simply add/subtract the offset given by the -linestart option for all indexes in 'line.character' format.
It would probably be prudent to make these functions inverses of each other.
CLASS METHODS
import
To make new Reindex widgets, this function should be called via use with the name of the Text-like base class that you are extending
with "Reindex" capability. 'use base(Tk::Reindex Tk::nameofbasewidget)' should also be specified for that widget.
BUGS
I've used the word "indexes" instead of "indices" throughout the documentation.
All the built-in perl code for widget bindings & methods will use the new 'user' indexes. Which means all this index manipulation might
might break code that is trying to parse/manipulate indexes. Or even assume that '1.0' is the beginning index. Tk::Text::Contents comes to
mind.
AUTHOR
Andrew Allen <ada@fc.hp.com>
This code may be distributed under the same conditions as Perl.
Tk1.1 2007-05-05 Reindex(3)