Subject: | Add to_hash? |
It would be nice if Slurp would provide some kind to_hash function,
maybe implemented like
map {chomp; ($_,1) } to_array($filename ...)
This kind of hash is useful for building existance maps, e.g. in the
BEGIN block of a perl one-liner, and then check the file contents with
this map:
perl -MSlurp=to_hash -nle 'BEGIN { %h = to_hash "existsfile" } print
if exists $h{$_}' somefile
Instead of using the value "1" as the hash value, the occurrence count
could be used instead, to have something similar like the "uniq -c" Unix
command.
Regards,
Slaven