Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^6: Data manipulation on a file

by CountZero (Bishop)
on Oct 02, 2015 at 21:23 UTC ( [id://1143684]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Data manipulation on a file
in thread Data manipulation on a file

Have a look at the uniq and distinct functions from List::MoreUtils.

For example:

use Modern::Perl qw/2015/; use List::MoreUtils qw/uniq/; my @mountpoints = qw/one two three three two four one one five six/; print join ' ', uniq sort @mountpoints;

Output: five four one six three two

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^7: Data manipulation on a file
by sstruthe (Novice) on Oct 02, 2015 at 21:38 UTC

    Thanks this looks really cool and straight forward. Should I just run this on the output string that has been dumped from the hash of arrays. wow you guys are great, perl is getting cool

      No, you run it on the array. The argument to uniq is an array or list, not a string.

      In your script it will be $outputstring .= "$filer:" . (join ' :', uniq sort @{$filer_hash{$filer}}) . ','; (untested)

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1143684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (1)
As of 2024-04-24 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found