help understanding perl hash -
Need help in understanding and if it can be written in a way that I can understand the use of Hashas more easily or eye?
In the summary, a regex does a script to filter the date and the remaining regex will drag data related to that date.
Use strict; Use warnings; Use continuous debug & gt; 0; My $ som = 'july'; My $ day = 28; My $ year = 2010; My% items = (); While (my $ line = <-bf;>) {chomp $ line; Print "line: $ line \ n" if debug; If ($ line = ~ m /(.* $ mon $ day) \ d {2}: \ d {2}: \ d {2} $ year: ([a-zA-Z0-9 ._] *) :. * /) {Print "### Scan \ n" If Debug; My $ date = $ 1; My $ set = $ 2; Print "$ date ($ set):" If debug; $ Item {$ set} - & gt; {'A-logdate'} = $ date; $ Item {$ set} - & gt; {'A-dataset'} = $ set; If ($ line = ~ m / (ERROR | backup-date | backup-sized | backup-time | backup-status) [: =] (. +) /) {My $ key = $ 1; My $ val = $ 2; $ Item {$ set} - & gt; {$ Key} = $ val; Print "$ key = $ val \ n" if debug; }}} Print "### Verify \ n"; For my $ set (ordered key% item) {print "set: $ set \ n"; My% info =% {$ item {$ set}}; For my $ key (sort keys% info) {printf "% s =% s;", $ k, $ info {$ key}; } Print "\ n"; }
I am trying to understand these lines are:
$ items {$ set} - & gt; {'A-logdate'} = $ date; $ Item {$ set} - & gt; {'A-dataset'} = $ set;
and then below the two lines:
$ item {$ set} - & gt; {$ Key} = $ val;
Is this an example of a hash reference? Hash of hash?
I think I'm confused with the use of {$ set}: - (
< There is a hash of code>% item hash references (conceptually, a hash of hash). In the $ set
key % item
and you have a And can withdraw the hash, which is being associated with 'a-logdate'
and 'a-dataset'
.
(True Based comments)
Comments
Post a Comment