sstruthe has asked for the wisdom of the Perl Monks concerning the following question:
Hi There, this is probably a really easy one for you monks out there. I have the following script, it's using awk for the main manipulation to read into the array a list of linux mount points. I find awk easier on delims than split and regex but thats because I know it.
#!/usr/bin/perl # use strict; use warnings; my $mounts = `mount | grep 'type nfs' | awk -F/ '{print \$1,\$3}' | so +rt`; print $mounts; mounts now looks like this but I have no idea how I read in the two co +lums into a hash of hosts with array of mountpoints. this is the file coming in but not in full host1 /var/mount1 host1 /var/mount2 host2 /var/mount5 host3 /var/mount3 host3 /usr/mount1
what I want coming out is
$mountpointkey=host1:/var/mount1:/var/mount2,host2:/var/mount5,host3:/var/mount3:/var/mount1 hope this makes sense appreciate any effort that comes my way from this many thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data manipulation on a file
by toolic (Bishop) on Sep 30, 2015 at 14:55 UTC | |
by sstruthe (Novice) on Sep 30, 2015 at 15:10 UTC | |
by toolic (Bishop) on Sep 30, 2015 at 15:16 UTC | |
by SuicideJunkie (Vicar) on Sep 30, 2015 at 17:13 UTC | |
by sstruthe (Novice) on Oct 01, 2015 at 09:30 UTC | |
by Corion (Patriarch) on Oct 01, 2015 at 09:34 UTC | |
| |
by sstruthe (Novice) on Oct 02, 2015 at 20:50 UTC | |
| |
|
Re: Data manipulation on a file
by karlgoethebier (Abbot) on Sep 30, 2015 at 17:34 UTC |