aravind.kalla has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Good day...!!

I am having a status log file which keeps a track of previous script run. As per requirement, need to compare the current run to the previous run and subsequently sends out notification alerts.

The status file content is build like a reference tree as below:

FreeTablespace_Status.log

$ref = { 'servername.com' => { 'DB01.com' => { 'TableSpace +' => { ' +Tablespace_Name' => { + 'OK' => 1, + 'Node' => 'servername.com', + 'Description' => 'Table Space threshold less th +an 90%', + 'UniqueID' => '12345667', + 'Severity' => 'Normal', + 'Title' => 'Servername table space threshold is + less' + }, ' +Tablespace_02' => { + 'OK' => 1, + 'Node' => 'servername.com', + 'Description' => 'Table Space threshold less than +90%', + 'UniqueID' => '3452555', + 'Severity' => 'Normal', + 'Title' => 'Servername-> tablespace02 threshold is + less' + } + } } }, 'servername02.com' => { 'DB02.com' => { 'TableSpace +' => { ' +Tablespace_01' => { + 'OK' => 1, + 'Node' => 'servername02.com', + 'Description' => 'Table Space threshold less th +an 90%', + 'UniqueID' => '0985433', + 'Severity' => 'Critical', + 'Title' => 'servername02 tablespace01 threshold + is less' + }, ' +Tablespace_02' => { + 'OK' => 1, + 'Node' => 'servername02.com', + 'Description' => 'Table Space threshold less than +90%', + 'UniqueID' => '4283289', + 'Severity' => 'Medium', + 'Title' => 'servername02-> tablespace02 threshold +is less' + } + } } }, }

I am looking to delete one reference Server01 content in the above. Looking for some help on this

2018-03-27 Athanasius added code and paragraph tags

Replies are listed 'Best First'.
Re: Delete reference tree from a file
by hippo (Archbishop) on Mar 27, 2018 at 13:43 UTC
    I am looking to delete one reference Server01 content in the above.

    There is no "Server01" in the above. Perhaps you have already successfully deleted it?

      My bad ...typo error its servername.com

        So, just delete that then.

        use strict; use warnings; use Test::More tests => 2; my $ref = { 'servername.com' => 'foo' }; ok (defined $ref->{'servername.com'}, 'Present'); delete $ref->{'servername.com'}; ok (!defined $ref->{'servername.com'}, 'Absent');
Re: Delete reference tree from a file
by Anonymous Monk on Mar 27, 2018 at 11:16 UTC