in reply to redirect stdout into hash

Where you are reading the data (the while ! eof section is probably where you want to do this. Instead of the print command, you would load it into a buffer for processing it into a hash.

The way that you are reading the text from $bigcmd will not give you data in any structured form, but just as a string of at most 1024 characters at a time. You will probably want to join the strings together, split them into the actual records (or use regular expressions), and then push them into a data structure.

One thing that may help get some more help on this is to list a small snippet of what the output looks like, as well as how the resulting output string should look.

Update: As zentara has also stated, if you are just looking to have a set of lines, and not structured data, reading the data into an array is likely a better option.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: redirect stdout into hash
by doctorspears (Novice) on Jun 13, 2012 at 17:49 UTC

    Thanks folks. The output file looks something like this, only bigger.

    WAFFINITY_NVLOG_COMPLETION = 170613544 0 0 169894032 FREE_CACHE_REFILL = 6071 35904 35904 22483 PURGE_FILE_PURGE = 173463 27149 27149 0 BUF_CACHE_REBALANCE = 27438 4841 4841 0 _WAFL_BACKDOOR = 85407891 10800645 10800645 0 ==================== = ======== ======== ======== ======== Totals = 645100944 11046000 11046000 799567928 msg_cnt (since boot) = 656146947 wafl restart count histogram: (432440632) -- simple counts 0 1 2 3 4 5 6 + 7 429360452 2285980 67923 2963 5226 10431 432485 82 +144 <16 <24 <32 <40 <48 <56 <64 UNUS +ED 135096 22222 9999 4529 2296 1869 1820 + 0 <128 <192 <256 <320 <384 <448 <512 UNUS +ED 7676 2625 1233 718 2225 718 2 + 0 Odd number of elements in hash assignment at ./waflsusp.pl line 36. <1024 <1536 <2048 <2560 <3072 <3584 <4096 UNUS +ED 0 0 0 0 0 0 0 + 0 <8192 <12288 <16384 <20480 <24576 <28672 <32768 UNUS +ED 0 0 0 0 0 0 0 + 0 <65536 <98304 <131072 <163840 <196608 <229376 <262144 >2621 +44 0 0 0 0 0 0 0 + 0 Average: 0.02

    Later I will be pulling various elements out of this data for evaluation. For example, there may be three fields retrieved by name where I need to perform some math on their values.

    Example:

    mycache-hit = 1000

    mycache-miss = 410

    mycache-miss-why = 309

    410/1000 = X, 309/410 = Y, etc etc