On 5/30/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
> Tielman Koekemoer (TNE) wrote:
> >
> >>Wow, I'm really confused. I'm trying to remove duplicate
> >>lines from a marc21 text file.  I have spent countless hours
> >>searching for scripts etc.
> >
> > I'm also very new to Perl and wrote a long and newbyish script that
> > does exactly what the Unix command "sort FILENAME | uniq" does just to
> > see how it can be done.
> 
> How long?  Because you can do that on one line in perl.  :-)
> 
> perl -e'print sort grep !$seen{$_}++, <>' FILENAME
> 
> 
> 
> John

You can also use just do:

    $seen{$_}++ while <>;
    print sort keys %seen;

Which will also let you know which items were repeated, and how many
times.  It al depends on what you ultimately want to do with the
information.  This is why we ask to see code you've tried, and where
you're headed.  There are probably close to 1,000 ways to handle this
in Perl, each of them appropriate for a specific circumstance.

In this case, doing a search for MARC and/or Z3950 on search.cpan.org
will turn up some interesting results, too

HTH,

-- jay
--------------------
daggerquill [at] gmail [dot] com
http://www.engatiki.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to