arrays - Use Perl to only print only if the value of column A appears with every different value of Column B -


so in perl how can go through sample file so:

1 d z 1 e f 1 g l  2 d 2 e l 3 d p 3 g l 

so here want able print out values have value in first column appears every different value of second column.

the output this:

1 d z 1 e f 1 g l  

cat test

1 d z

1 e f

1 g l

2 d i

2 e l

3 d p

3 g l

perl -a -lne 'unless ( $h{ $f[1] } ) { print }; $h{ $f[1] } = 1; ' test

1 d z

1 e f

1 g l


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -