Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: File Parsing Question

by tybalt89 (Monsignor)
on Apr 06, 2021 at 16:31 UTC ( [id://11130905]=note: print w/replies, xml ) Need Help??


in reply to File Parsing Question

One way to "back up" :)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11130900 use warnings; local $_ = <<END; ok: [cgva1lbpmor001m] => { "result.stdout_lines": [ "SOURCE FSTYPE SIZE USED AVAIL USE% TA +RGET", "kmhpemcfspa21:/oracle_depot nfs 130.1G 77.2G 52.9G 59% /e +xport/oracle", "kmhpemcfspa21:/oracle_dump nfs 11.5T 1.8T 9.7T 16% /e +xport/oracle_dump" ] } ok: [otherhost] => { "result.stdout_lines": [ "SOURCE FSTYPE SIZE USED AVAIL USE% TA +RGET", "kmhpemcfspa21:/oracle_dump nfs 11.5T 1.8T 9.7T 16% /e +xport/oracle_dump" ] } ok: [thirdhost] => { "result.stdout_lines": [ "SOURCE FSTYPE SIZE USED AVAIL USE% TA +RGET", "kmhpemcfspa21:/oracle_other nfs 11.5T 1.8T 9.7T 16% /e +xport/oracle_dump" "kmhpemcfspa21:/oracle_depot nfs 130.1G 77.2G 52.9G 59% /e +xport/oracle", ] } END my %hostspershare; while( /"(\S+)\s+nfs\s/g ) { my $share = $1; $` =~ /.*ok: \[(\S+?)\]/s and push @{ $hostspershare{$share} }, $1; } use Data::Dump 'dd'; dd \%hostspershare;

Outputs:

{ "kmhpemcfspa21:/oracle_depot" => ["cgva1lbpmor001m", "thirdhost"], "kmhpemcfspa21:/oracle_dump" => ["cgva1lbpmor001m", "otherhost"], "kmhpemcfspa21:/oracle_other" => ["thirdhost"], }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found