i'm trying to print the unique keys of a datafile.
my key indexes are 0,1,2,3 and my delimiter is
^
4363^7619082^309839685^309841122^14^18
4363^7619082^309839685^309841122^14^19
4363^7619082^309839685^309841122^14^20
4363^7619082^309839685^309841122^26^25
4363^7619082^309839685^309841122^26^26
4363^7619082^309839685^309841122^14^52
4363^7619082^309839685^309841122^14^51
4363^7619082^309839685^309841122^23^21
this code works:
perl -ne '@ar = split /\^/; $key="$ar[0],$ar[1],$ar[2],$ar[3]\n"; pri
+nt $key if ( ! $seen{$key} ++ );' datafile
but i want to use
-F like so:
perl -naF^ -e '$key="$F[0],$F[1],$F[2],$F[3]\n"; print $key if ( ! $se
+en{$key} ++ );' datafile
or
-F/^/
-F/\^/
-F"^"
-F'^'
but it wont split!
any suggestions?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.