Sponsored Content
Full Discussion: Help with array comparison
Top Forums UNIX for Dummies Questions & Answers Help with array comparison Post 302258008 by ChicagoBlues on Thursday 13th of November 2008 03:56:00 PM
Old 11-13-2008
Help with array comparison

I have an array @name with the below contents (index 7 and 8 are names):

1|1|2|2|I|2|0|DUNN|LACY||||||
2|2|2|2|I|2|0|KOFE|ROGER||||||
3|3|2|2|A|2|0|KOFOED|ROBERT||||||
3|4|2|2|A|2|0|KOFOED|ROBERT||||||
3|5|2|2|A|2|0|KOFOED|ROBERT||||||
2|7|2|2|I|2|0|WILLIAMSON|JAMES||||||
3|8|2|2|I|2|0|MUNN|MARION||||||
4|9|2|2|A|2|0|BLOCK|ROY||||||

I want to remove the duplicates, from the list @name:

1|1|2|2|I|2|0|DUNN|LACY||||||
2|2|2|2|I|2|0|KOFE|ROGER||||||
3|3|2|2|A|2|0|KOFOED|ROBERT||||||
2|7|2|2|I|2|0|WILLIAMSON|JAMES||||||
3|8|2|2|I|2|0|MUNN|MARION||||||
4|9|2|2|A|2|0|BLOCK|ROY||||||

I need help with a unique list of names (ignore the other fields).

Thanks,

- CB
 

10 More Discussions You Might Find Interesting

1. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

2. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

3. Shell Programming and Scripting

Awk multiple variable array: comparison

Foo.txt 20 40 57 50 22 51 66 26 17 15 63 18 80 46 78 99 87 2 14 14 51 47 49 100 58 Bar.txt 20 22 51 15 63 78 99 55 51 58 How to get output using awk 20 22 57 50 51 15 26 17 63 78 80 46 99 55 - - 51 58 49 100 (5 Replies)
Discussion started by: genehunter
5 Replies

4. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

5. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

6. Homework & Coursework Questions

passing letters from an array into a string for string comparison

attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now. ##I have an array $wordString that initializes to a string of dashes ##reflecting the number of letters in $theWord ##every time the user enters a (valid)... (5 Replies)
Discussion started by: lotsofideas
5 Replies

7. Shell Programming and Scripting

Array elements comparison using perl

Experts, I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this. my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name) my... (1 Reply)
Discussion started by: solaix14
1 Replies

8. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

9. Shell Programming and Scripting

Using associative array for comparison

Hello together, i make something wrong... I want an array that contains information to associate it for further processing. Here is something from my bash... You will know, what I'm trying to do. I have to point out in advance, that the variable $SYSOS is changing and not as static as in my... (2 Replies)
Discussion started by: Decstasy
2 Replies

10. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies
Template::View(3)					User Contributed Perl Documentation					 Template::View(3)

NAME
Template::View - customised view of a template processing context SYNOPSIS
# define a view [% VIEW view # some standard args prefix => 'my_', suffix => '.tt2', notfound => 'no_such_file' ... # any other data title => 'My View title' other_item => 'Joe Random Data' ... %] # add new data definitions, via 'my' self reference [% my.author = "$abw.name <$abw.email>" %] [% my.copy = "&copy; Copyright 2000 $my.author" %] # define a local block [% BLOCK header %] This is the header block, title: [% title or my.title %] [% END %] [% END %] # access data items for view [% view.title %] [% view.other_item %] # access blocks directly ('include_naked' option, set by default) [% view.header %] [% view.header(title => 'New Title') %] # non-local templates have prefix/suffix attached [% view.footer %] # => [% INCLUDE my_footer.tt2 %] # more verbose form of block access [% view.include( 'header', title => 'The Header Title' ) %] [% view.include_header( title => 'The Header Title' ) %] # very short form of above ('include_naked' option, set by default) [% view.header( title => 'The Header Title' ) %] # non-local templates have prefix/suffix attached [% view.footer %] # => [% INCLUDE my_footer.tt2 %] # fallback on the 'notfound' template ('my_no_such_file.tt2') # if template not found [% view.include('missing') %] [% view.include_missing %] [% view.missing %] # print() includes a template relevant to argument type [% view.print("some text") %] # type=TEXT, template='text' [% BLOCK my_text.tt2 %] # 'text' with prefix/suffix Text: [% item %] [% END %] # now print() a hash ref, mapped to 'hash' template [% view.print(some_hash_ref) %] # type=HASH, template='hash' [% BLOCK my_hash.tt2 %] # 'hash' with prefix/suffix hash keys: [% item.keys.sort.join(', ') [% END %] # now print() a list ref, mapped to 'list' template [% view.print(my_list_ref) %] # type=ARRAY, template='list' [% BLOCK my_list.tt2 %] # 'list' with prefix/suffix list: [% item.join(', ') %] [% END %] # print() maps 'My::Object' to 'My_Object' [% view.print(myobj) %] [% BLOCK my_My_Object.tt2 %] [% item.this %], [% item.that %] [% END %] # update mapping table [% view.map.ARRAY = 'my_list_template' %] [% view.map.TEXT = 'my_text_block' %] # change prefix, suffix, item name, etc. [% view.prefix = 'your_' %] [% view.default = 'anyobj' %] ... DESCRIPTION
TODO METHODS
new($context, \%config) Creates a new Template::View presenting a custom view of the specified $context object. A reference to a hash array of configuration options may be passed as the second argument. prefix Prefix added to all template names. [% USE view(prefix => 'my_') %] [% view.view('foo', a => 20) %] # => my_foo suffix Suffix added to all template names. [% USE view(suffix => '.tt2') %] [% view.view('foo', a => 20) %] # => foo.tt2 map Hash array mapping reference types to template names. The print() method uses this to determine which template to use to present any particular item. The TEXT, HASH and ARRAY items default to 'test', 'hash' and 'list' appropriately. [% USE view(map => { ARRAY => 'my_list', HASH => 'your_hash', My::Foo => 'my_foo', } ) %] [% view.print(some_text) %] # => text [% view.print(a_list) %] # => my_list [% view.print(a_hash) %] # => your_hash [% view.print(a_foo) %] # => my_foo [% BLOCK text %] Text: [% item %] [% END %] [% BLOCK my_list %] list: [% item.join(', ') %] [% END %] [% BLOCK your_hash %] hash keys: [% item.keys.sort.join(', ') [% END %] [% BLOCK my_foo %] Foo: [% item.this %], [% item.that %] [% END %] method Name of a method which objects passed to print() may provide for presenting themselves to the view. If a specific map entry can't be found for an object reference and it supports the method (default: 'present') then the method will be called, passing the view as an argument. The object can then make callbacks against the view to present itself. package Foo; sub present { my ($self, $view) = @_; return "a regular view of a Foo "; } sub debug { my ($self, $view) = @_; return "a debug view of a Foo "; } In a template: [% USE view %] [% view.print(my_foo_object) %] # a regular view of a Foo [% USE view(method => 'debug') %] [% view.print(my_foo_object) %] # a debug view of a Foo default Default template to use if no specific map entry is found for an item. [% USE view(default => 'my_object') %] [% view.print(objref) %] # => my_object If no map entry or default is provided then the view will attempt to construct a template name from the object class, substituting any sequence of non-word characters to single underscores, e.g. # 'fubar' is an object of class Foo::Bar [% view.print(fubar) %] # => Foo_Bar Any current prefix and suffix will be added to both the default template name and any name constructed from the object class. notfound Fallback template to use if any other isn't found. item Name of the template variable to which the print() method assigns the current item. Defaults to 'item'. [% USE view %] [% BLOCK list %] [% item.join(', ') %] [% END %] [% view.print(a_list) %] [% USE view(item => 'thing') %] [% BLOCK list %] [% thing.join(', ') %] [% END %] [% view.print(a_list) %] view_prefix Prefix of methods which should be mapped to view() by AUTOLOAD. Defaults to 'view_'. [% USE view %] [% view.view_header() %] # => view('header') [% USE view(view_prefix => 'show_me_the_' %] [% view.show_me_the_header() %] # => view('header') view_naked Flag to indcate if any attempt should be made to map method names to template names where they don't match the view_prefix. Defaults to 0. [% USE view(view_naked => 1) %] [% view.header() %] # => view('header') print( $obj1, $obj2, ... \%config) TODO view( $template, \%vars, \%config ); TODO AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 2000-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin perl v5.12.1 2009-05-20 Template::View(3)
All times are GMT -4. The time now is 07:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy