Need help in filters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in filters
# 8  
Old 11-10-2009
Code:
#!/usr/bin/perl

use strict;
use warnings;

while(my $line = <>){
        chomp $line;
        $line =~ s/\s+//g;
        my @cols = split(';',$line);
        my %hash;
        for(my $i=0;$i<=$#cols;$i++){
                if (exists $hash{$cols[$i]} && $hash{$cols[$i]} eq $cols[$i+1]){
                        print "$line is a repeat \n";
                        last;
                }
                else {
                        $hash{$cols[$i]} = $cols[$i+1];
                         $i++;
                }
        }
}

the script can be called as

cat abc.txt | perl scriptname.pl

or it can be copied on the command line as well.

HTH,
PL
# 9  
Old 11-11-2009
Hi Daptal

gettting error

ksh: use: not found.
ksh: 0403-057 Syntax error: `)' is not expected.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Creating filters with Python on excel

Hello, I have an excel sheet with 11 tabs. I need to take data from the first tab and write the output to the second tab. The first tab looks like this, starting from Row 3 The filters that needs to be created are 1) keep anything greater than 'POS' 5 and less than 160 AND 2)... (2 Replies)
Discussion started by: nans
2 Replies

2. Programming

Applying filters

I have a value X, a value DX and an odd integer N (say N=9) and want to create an array such that let X = 10, DX = 2 and N = 9 DIST(1) = X - 4 * DX DIST(2) = X - 3 * DX DIST(3) = X - 2 * DX DIST(4) = X - DX DIST(5) = X DIST(6) = X + DX DIST(7) = X + 2 * DX DIST(8) = X + 3 * DX DIST(9)... (2 Replies)
Discussion started by: kristinu
2 Replies

3. UNIX for Advanced & Expert Users

Unix- filters ppt

Hello.. i want a ppt on unix filters.. can anybody gv me d link 4 that?? (1 Reply)
Discussion started by: shweta_babbar
1 Replies

4. UNIX for Dummies Questions & Answers

Difference between filters of ps

Hi I am a newbie to Unix . I am just trying to understand the difference between various filters for ps. Can someoen pelase explain me whta is the difference between using /usr/bin/ps -ef | grep <PID> or <Process name> and /usr/bin/ps -auxwww| grep <PID> or <Process Name>. (1 Reply)
Discussion started by: sillybirdie123
1 Replies

5. UNIX for Dummies Questions & Answers

filters

how to filter one particular row from one text file and copy it in another? (1 Reply)
Discussion started by: rajanandhini
1 Replies

6. UNIX for Dummies Questions & Answers

How can I use filters to extract infos?

I encountered some complicated problems course studies. take this for example: under /home/data/stockdata we have 1999,2000,2001,.......2004 these sub-dirs and, each sub-dir has its mothly(for Jan~Dec) transaction records, i.e. they are all named "foo.txt", like this: Date ... (2 Replies)
Discussion started by: virii
2 Replies

7. Solaris

Solaris lp printer filters

I don't have much experience with solaris printers. I've created a printer using lpadmin. When I tried to print something, I got a message that there a no filters on the server. I went to docs.sun.com and got a script to add a filter (below) for filter in *.fd;do >name=`basename $filter... (1 Reply)
Discussion started by: soliberus
1 Replies

8. UNIX for Dummies Questions & Answers

IP Filters

Anyone know where I can find good documentation for IPF on the Internet? Thanks, Chuck (1 Reply)
Discussion started by: 98_1LE
1 Replies
Login or Register to Ask a Question