![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grabbing variables and comparing | kerpm | Shell Programming and Scripting | 9 | 08-17-2008 06:45 PM |
| comparing 2 string variables in unix | katdaniel16 | UNIX for Dummies Questions & Answers | 17 | 07-23-2008 03:25 AM |
| comparing content of 2 variables in script | sam4now | Shell Programming and Scripting | 5 | 04-24-2008 03:42 PM |
| Comparing two variables | rajip23 | Shell Programming and Scripting | 3 | 04-11-2008 06:45 AM |
| comparing variables | MizzGail | UNIX for Dummies Questions & Answers | 3 | 02-08-2008 01:53 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Can you explain the comparison that you are looking for?
Is it one to one: Code:
if ($a[0] = $b[0])
{
your code here
}
Code:
for (@a){
if ($b[0] = $_)
{
your code here
}
}
|
|
||||
|
Quote:
To compare numbers use "==" to compare strings use "eq", of course sometimes its never that simple but it looks like it would be in this case if the examples are what is really being compared. There are also modules that compare arrays, one I believe is called Array::Compare |
|
||||
|
If you wanted to loop through each element in an array to do a one-to-one evaluation for each element pair in an array, you can:
Code:
$elementCount = @a;
$count = 0;
while ( $count < $elementCount )
{
if ( $a[$count] == $b[$count] )
{
print "\$a[$count]: $a[$count] = \$b[$count]: $b[$count]\n";
}
$count++;
}
EDIT: changed line in red |
|
||||
|
Thanks Kevin - yes, I didn't go back to edit my first post (it started out as a basic framework) that morphed into a "code sample".
If you'll notice my second post in this thread does provide an actual comparison . Cheers! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|