Sponsored Content
Full Discussion: Perl - Compare 2 Arrays
Top Forums Shell Programming and Scripting Perl - Compare 2 Arrays Post 302230252 by summer_cherry on Thursday 28th of August 2008 11:36:49 PM
Old 08-29-2008
Hi,

Is it ok for you to use some other command.

try below one:

Code:
paste -d"," file1 file2 > temp.txt
awk '{
if ($1=$5 && $2==$6 && $3==$7 && $4==$8)
print true
}' temp.txt
rm temp.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two arrays in sh or compare two fields

I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies

2. Shell Programming and Scripting

compare/match arrays

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)
Discussion started by: draco
3 Replies

3. Shell Programming and Scripting

Compare arrays in perl

Hello, Let's say that we have the two following arrays @array1= @array2= Is there any easy way to compare these two arrays and print the values that exist in array1 and not in array2 and the values that exist in array2 and not in array1? Regards, Chriss_58 (3 Replies)
Discussion started by: chriss_58
3 Replies

4. Shell Programming and Scripting

compare 2 arrays in perl

Hi Im supposed to compare lines in a file : KB0005 1019 T IFVATVPVI 0.691 PKC YES KB0005 1036 T YFLQTSQQL 0.785 PKC YES KB0005 1037 S FLQTSQQLK 0.585 DNAPK YES KB0005 1045 S KQLESEGRS 0.669 PKC YES KB0005 1045 S KQLESEGRS 0.880 unsp YES KB204320 1019 T IFVATVPVI 0.699 PKC YES ... (7 Replies)
Discussion started by: karla
7 Replies

5. Shell Programming and Scripting

Compare arrays (perl)

Hi, my first post here! Description of my problem: I have one txt-file with six rows and each row contains seven numbers seperated with whitespaces. I want to: Compare one array with seven numbers with each row of numbers in the txt-file. I have managed to compare one array with... (6 Replies)
Discussion started by: mjoh
6 Replies

6. Shell Programming and Scripting

Perl Compare 2 Arrays

Hello, Consider the following 2 arrays: Array1 = qw(Fa0/0 Fa0/1 Fa0/2 Fa0/3); Array1 = qw(Fa0/1 Fa0/2 Fa0/3 Fa0/4); I want to compare the following 2 arrays as follows: Take specific action when elements of Array1 that doesn't exist in Array2 (in my example: Fa0/0). Take another... (4 Replies)
Discussion started by: ahmed_zaher
4 Replies

7. Shell Programming and Scripting

perl: compare two arrays

Hi friends, I want to compare two arrays and find matched one using perl? Also, I want to delete unmatched one. Plz suggest me solution (1 Reply)
Discussion started by: Renesh
1 Replies

8. Shell Programming and Scripting

Compare two arrays

Hi, I am trying to compare two lists that are held in two variables so I believe I need to access the array elements to compare these. I am using ksh 88 and the code I have tried is below: for file in ${origfilelist} do if ]] then print -- "File ${file}... (3 Replies)
Discussion started by: frodo61
3 Replies

9. Shell Programming and Scripting

Using Diff to compare 2 arrays

I have two arrays and they look like this: array=(`cat /local/mnt/*sys/*includes|grep -v NEW`) array2=(`cat /tmp/*sys.z |grep -v NEW`) I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do diff -u ${array} ${array2} I cannot... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. UNIX for Beginners Questions & Answers

Compare bash arrays issue

Hello everyone, I need help comparing 2 arrays. the first array is static; the second array is not .. array1=( "macOS Mojave" "iTunes" ) cd /Volumes array2=( * ) # output of array2 macOS Mojave iTunes Mac me The problem occurs when I compare the arrays with the following code - ... (6 Replies)
Discussion started by: trexthurman
6 Replies
SDL_PixelFormat(3)						 SDL API Reference						SDL_PixelFormat(3)

NAME
SDL_PixelFormat- Stores surface format information STRUCTURE DEFINITION
typedef struct{ SDL_Palette *palette; Uint8 BitsPerPixel; Uint8 BytesPerPixel; Uint32 Rmask, Gmask, Bmask, Amask; Uint8 Rshift, Gshift, Bshift, Ashift; Uint8 Rloss, Gloss, Bloss, Aloss; Uint32 colorkey; Uint8 alpha; } SDL_PixelFormat; STRUCTURE DATA
palette Pointer to the palette, or NULL if the BitsPerPixel>8 BitsPerPixel The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32. BytesPerPixel The number of bytes used to represent each pixel in a surface. Usually one to four. [RGBA]mask Binary mask used to retrieve individual color values [RGBA]loss Precision loss of each color component (2^[RGBA]loss) [RGBA]shift Binary left shift of each color component in the pixel value colorkey Pixel value of transparent pixels alpha Overall surface alpha value DESCRIPTION
A SDL_PixelFormat describes the format of the pixel data stored at the pixels field of a SDL_Surface. Every surface stores a SDL_PixelFor- mat in the format field. If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential. 8-bit pixel formats are the easiest to understand. Since its an 8-bit format, we have 8 BitsPerPixel and 1 BytesPerPixel. Since BytesPer- Pixel is 1, all pixels are represented by a Uint8 which contains an index into palette->colors. So, to determine the color of a pixel in a 8-bit surface: we read the color index from surface->pixels and we use that index to read the SDL_Color structure from surface->for- mat->palette->colors. Like so: SDL_Surface *surface; SDL_PixelFormat *fmt; SDL_Color *color; Uint8 index; . . /* Create surface */ . . fmt=surface->format; /* Check the bitdepth of the surface */ if(fmt->BitsPerPixel!=8){ fprintf(stderr, "Not an 8-bit surface. "); return(-1); } /* Lock the surface */ SDL_LockSurface(surface); /* Get the topleft pixel */ index=*(Uint8 *)surface->pixels; color=fmt->palette->colors[index]; /* Unlock the surface */ SDL_UnlockSurface(surface); printf("Pixel Color-> Red: %d, Green: %d, Blue: %d. Index: %d ", color->r, color->g, color->b, index); . . Pixel formats above 8-bit are an entirely different experience. They are considered to be "TrueColor" formats and the color information is stored in the pixels themselves, not in a palette. The mask, shift and loss fields tell us how the color information is encoded. The mask fields allow us to isolate each color component, the shift fields tell us the number of bits to the right of each component in the pixel value and the loss fields tell us the number of bits lost from each component when packing 8-bit color component in a pixel. /* Extracting color components from a 32-bit color value */ SDL_PixelFormat *fmt; SDL_Surface *surface; Uint32 temp, pixel; Uint8 red, green, blue, alpha; . . . fmt=surface->format; SDL_LockSurface(surface); pixel=*((Uint32*)surface->pixels); SDL_UnlockSurface(surface); /* Get Red component */ temp=pixel&fmt->Rmask; /* Isolate red component */ temp=temp>>fmt->Rshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Rloss; /* Expand to a full 8-bit number */ red=(Uint8)temp; /* Get Green component */ temp=pixel&fmt->Gmask; /* Isolate green component */ temp=temp>>fmt->Gshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Gloss; /* Expand to a full 8-bit number */ green=(Uint8)temp; /* Get Blue component */ temp=pixel&fmt->Bmask; /* Isolate blue component */ temp=temp>>fmt->Bshift;/* Shift it down to 8-bit */ temp=temp<<fmt->Bloss; /* Expand to a full 8-bit number */ blue=(Uint8)temp; /* Get Alpha component */ temp=pixel&fmt->Amask; /* Isolate alpha component */ temp=temp>>fmt->Ashift;/* Shift it down to 8-bit */ temp=temp<<fmt->Aloss; /* Expand to a full 8-bit number */ alpha=(Uint8)temp; printf("Pixel Color -> R: %d, G: %d, B: %d, A: %d ", red, green, blue, alpha); . . . SEE ALSO
SDL_Surface, SDL_MapRGB SDL
Tue 11 Sep 2001, 23:01 SDL_PixelFormat(3)
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy