in reply to Make unique hash of arrays?

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11147618 use warnings; my %uniq = map { s/.*\n//r, $_ } do { local $/ = "//\n"; <DATA> }; print values %uniq; __DATA__ nick AAAAAAAAAA BBBBBBBBBB // george EGRGERHTETEHTHR VFRTTHTRRHTE // andreas AAAAAAAAAA BBBBBBBBBB // thomas EWTRYTUYJTHT CEWWEQRWT$G // peter EGRGERHTETEHTHR VFRTTHTRRHTE //

Replies are listed 'Best First'.
Re^2: Make unique hash of arrays?
by Anonymous Monk on Oct 24, 2022 at 16:55 UTC

    Notes:

    • This needs use v5.14.0 (or equivalent) for s///r.
    • The local $/ = "//\n" changes the diamond operator's notion of what a line is, causing it to read the file in chunks delimited by "//\n".