Sponsored Content
Top Forums Shell Programming and Scripting PHP Compare 2 Arrays find difference & case insensitive Post 302384096 by summer_cherry on Monday 4th of January 2010 01:54:18 AM
Old 01-04-2010
a perl sample script
Code:
my @tmp1=qw(This is the data of array1);
my @tmp2=qw(this is the data of array2);
sub comp{
	my @t1=@{$_[0]};
	my @t2=@{$_[1]};
	my $flag=$_[2] || 'Y';
	foreach my $item (@t2){
		my $reg = ($flag eq 'N')?qr/$item/i:qr/$item/;
		my $cnt = () = grep {$_=~/$reg/} @t1;
		#print "-->",$item,"-->",$cnt,"\n";
		print $item,"\n" if $cnt == 0;
	}
}
comp(\@tmp1,\@tmp2,'N');

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

case insensitive locate

How can I do a case insensitive locate? (3 Replies)
Discussion started by: davis.ml
3 Replies

2. Shell Programming and Scripting

awk case-insensitive

can I tell awk to be case insensitive for one operation without setting the ignorecase value ? thanks, Steffen (7 Replies)
Discussion started by: forever_49ers
7 Replies

3. Shell Programming and Scripting

case insensitive

hi everyone, I need to do the following thing in a case insesitive mode sed 's/work/job/g' filename since work could appear in different form as Work WORK WorK wORK,.... I was wondering if i could do a case insensitive search of a word. thanks in advance, :) (4 Replies)
Discussion started by: ROOZ
4 Replies

4. Shell Programming and Scripting

case-insensitive if on substring

I'd like to print a line if a substring is matched in a case insensitive manner something like do a case insensitive search for ABCD as a substring: awk '{ if (substr($1,1,4) == "") print $1 }' infile > outfile I'm not certain how to make the syntax work??? Thanks (4 Replies)
Discussion started by: dcfargo
4 Replies

5. Shell Programming and Scripting

How to find difference between two arrays in Perl?

Hi, Could someone please help me with this? I have two arrays and I need to generate third array containing difference between the two. For example - @Array1 = ; @Array2 = ; I would like to find difference between these two and generate third array that contains the difference. In... (5 Replies)
Discussion started by: sncoupons
5 Replies

6. Shell Programming and Scripting

Case Insensitive search

Hey , i am trying to do a search for the certain books , and im trying to make it case insensitive. what i have come up with so far is this : Database.txt RETARDED MONKEY:RACHEAL ABRAHAML:30:30:20 GOLD:FATIN:23.20:12:3 STUPID:JERLYN:20:40:3 echo -n "Title: " read Title echo -n... (3 Replies)
Discussion started by: gregarion
3 Replies

7. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

8. UNIX for Dummies Questions & Answers

Using sed for case insensitive search

Hi, I have a file named "test_file" that has the below content. It has words in upper/lower cases PRODOPS prodOPS ProdOps PRODops escalate Shell My requirement is to replace all the "prodops" (what ever case it may be) with "productionoperations". I tried using the "i" option with... (7 Replies)
Discussion started by: sbhuvana20
7 Replies

9. UNIX for Dummies Questions & Answers

Using FIND with case insensitive search

I am using HP-Unix B.11.31. Question: How to do the case insensitive search using FIND? Example: I would like list the files with extension of *.SQL & *.sql. When I try with command find . -type f -name *.sql, it does not lists file with *.SQL. (5 Replies)
Discussion started by: Siva SQL
5 Replies

10. UNIX for Dummies Questions & Answers

Find & Replace with same case letters

I have text with upper and lower case words. I want to find something and replace it with something new. But it should match the case - Meaning - it should replace old upper cased word with NEW upper case word and lower with lower. example: this text is very simple TEXT. now I want to replace... (5 Replies)
Discussion started by: grep_me
5 Replies
DtComboBoxAddItem(library call) 										   DtComboBoxAddItem(library call)

NAME
DtComboBoxAddItem -- add an item to the ComboBox widget SYNOPSIS
#include <Dt/ComboBox.h> void DtComboBoxAddItem( Widget w, XmString item, int pos, Boolean unique); DESCRIPTION
Note: This function has been superseded by the equivalent Motif function, XmComboBoxAddItem. Please refer to the Motif Programmer's Refer- ence for more information. The DtComboBoxAddItem function adds the given item to the DtComboBox at the given position. The w argument specifies the DtComboBox widget ID. The item argument specifies the XmString for the new item. The pos argument specifies the position of the new item. The unique argument specifies if this item should duplicate an identical item or not. RETURN VALUE
The DtComboBoxAddItem function returns no value. APPLICATION USAGE
The functions DtComboBoxAddItem and DtComboBoxDeletePos have different naming conventions (Item versus Pos) because of the objects they are manipulating. The Item is a string to be added, the Pos is a numeric position number. SEE ALSO
DtComboBox(3), DtComboBoxDeletePos(3), DtComboBoxSetItem(3), DtComboBoxSelectItem(3). DtComboBoxAddItem(library call)
All times are GMT -4. The time now is 01:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy