I know what I want to do but I can't find the right syntax to accomplish it. I get pieces of the puzzle, but I can't solve all of them to put them together. So I'll give an example hash of what I have, and the End result I'm looking for, and some pieces that I have solved. I tried to get some answers to single questions but there seem to be so many ways to accomplish them, I don't know how to take the answer and use it to what I understand how to solve my problem. So Here goes, I'm going to try to be as detailed as possible so I'm sorry if it gets long. To get this data I'm parsing a XML file and printing to a .tex file.

My goal is to pars an XML file and pull out all the different types of buttons and numeric entries and collect them in a hash (I know how to do this), Then I need to create a document that will have this data sorted in columns to display on a table. I need to be able to count 14 max per page while going through screens with varying numbers of buttons. At the end of each button that is not the last button I need a partial line "\cline{2-11}". At the end of all buttons of one screen I need a full horizontal Line "\hline". At the end of the page(14lines) I need to enter"\hline\pagebreak". I'm going to change the 14 Line for this to 5 so that not as much data is needed.


Here is my example Hash

use warnings; use strict; use Data::Dumper; my %hash = ( 'Alarms.Alarm Acknowledge' => { 'ScreenName' => 'Alarms', 'Description' => 'Alarm Acknowledge', 'Type' => 'On/Off' }, 'Flow Diagram.Sequence Hold' => { 'ScreenName' => 'Flow Diagram', 'Description' => 'Sequence Hold', 'Type' => 'Momentary' }, 'Flow Diagram.Sequence Advance' => { 'ScreenName' => 'Flow Diagram', 'Description' => 'Sequence Advance', 'Type' => 'Momentary' }, 'Flow Diagram.Sanitize Enable/Disable' => { 'ScreenName' => 'Flow Diagram', 'Description' => 'Sanitize Enable/Disable', 'Type' => 'On/Off' }, 'Trend to USB.Start/Stop Trend Toggle' => { 'ScreenName' => 'Trend to USB', 'Description' => 'Start/Stop Trend Toggle', 'Type' => 'On/Off' }, 'Alarms.Alarm Reset' => { 'ScreenName' => 'Alarms', 'Description' => 'Alarm Reset', 'Type' => 'On/Off' }, 'Alarms.Alarm Trigger' => { 'ScreenName' => 'Alarms', 'Description' => 'Alarm Trigger', 'Type' => 'Momentary' }, ); print Dumper(%hash); print "\n\n\n"; my %ScreenNameCount; $ScreenNameCount{$hash{$_}{ScreenName}}++ foreach keys %hash; my %HashCount; my $Screenkey = 'New'; my $ScreenkeyOld = 'Old'; my @List; my $i = 1; foreach my $key (sort keys %hash) { my $Screenkey = $hash{$key}{'ScreenName'}; my $Description = $hash{$key}{'Description'}; my $Type = $hash{$key}{'Type'}; $HashCount{$Screenkey} = $Screenkey; $HashCount{$Screenkey}= {0 => $ScreenNameCount{$Screenkey}}; if ($Screenkey eq $ScreenkeyOld) { $HashCount{$Screenkey} = {$i => "\\t \\t \\t \\t\& \\mytabhead{$De +scription} \\t\& $Type \\t\\\\ \\hline \\n $i - $Screenkey - $Screenk +eyOld"}; $i++; } else { $HashCount{$Screenkey} = {$i => "\\mytabhead{$Screenkey} \\t\& \\m +ytabhead{$Description} \\t\& $Type \\t\\\\ \\hline \\n $i - $Screenke +y - $ScreenkeyOld"}; $i=1; } $ScreenkeyOld = $Screenkey; } print "\n\n\n"; print Dumper(%HashCount); print "\n\n\n"; print Dumper \%ScreenNameCount; print "\n\n\n";

The .tex file should look what is below. "Trend to USB" has one button, so since the first button is the last it needs to end with \hline. "Alarms" has three and they all fit on the same page so the first 2 buttons end in \cline {2-11} and the last end in \hline. "Flow Diagram" has three buttons also but there is only room for one more button on the page. So the first button will end in \hline \pagebreak thus ending the page and restarting the count to 5. The next two buttons follow the same format, First button on the new page (the Second Flow Diagram Button) will end in \Cline{2-11}, and the last will end in \hline. The first button on the page must also start with "\\mytabhead{Flow Diagram}" verses the three tabs.


\multirow{1}{0.85in}{\mytabhead{Trend to USB}} & \mytabhead{Start/ +Stop Trend Toggle} & On/Off \hline \multirow{3}{0.85in}{\mytabhead{Alarms}} & \mytabhead{Alarm Tr +igger} & Momentary \cline{2-11} & \mytabhead{Alarm Ack +nowledge} & On/Off \cline{2-11} & \mytabhead{Alarm Res +et} & On/Off \hline \multirow{1}{0.85in}{\mytabhead{Alarms}} & \mytabhead{Sequence + Advance} & Momentary \hline\pagebreak \multirow{2}{0.85in}{\mytabhead{Alarms}} & \mytabhead{Sequence + Hold} & On/Off \cline{2-11} & \mytabhead{Sanitize +Enable/Disable} & On/Off \hline

I'm able to get the hash to look like this with the code above:


$VAR1 = 'Trend to USB'; $VAR2 = { '3' => '\\mytabhead{Trend to USB} \\t& \\mytabhead{Start/Sto +p Trend Toggle} \\t& On/Off \\t\\\\ \\hline \\n 3 - Trend to USB - Fl +ow Diagram' }; $VAR3 = 'Alarms'; $VAR4 = { '2' => '\\t \\t \\t \\t& \\mytabhead{Alarm Trigger} \\t& Mom +entary \\t\\\\ \\hline \\n 2 - Alarms - Alarms' }; $VAR5 = 'Flow Diagram'; $VAR6 = { '2' => '\\t \\t \\t \\t& \\mytabhead{Sequence Hold} \\t& Mom +entary \\t\\\\ \\hline \\n 2 - Flow Diagram - Flow Diagram' };

When I want it to look like this:


$VAR1 = 'Trend to USB'; $VAR2 = { '0' => 1, '1' => '\\mytabhead{Trend to USB} \\t& \\mytabhead{Start/Sto +p Trend Toggle} \\t& On/Off \\t\\\\ \\hline \\n 1 - Trend to USB - Ol +d' }; $VAR3 = 'Alarms'; $VAR4 = { '0' => 3, '1' => '\\mytabhead{Alarms} \\t& \\mytabhead{Alarm Trigger} + \\t& Momentary \\t\\\\ \\hline \\n 1 - Alarms - Trend to USB' '2' => '\\t \\t \\t \\t& \\mytabhead{Alarm Acknowledge} \\t& + On/Off \\t\\\\ \\hline \\n 2 - Alarms - Alarms' '3' => '\\t \\t \\t \\t& \\mytabhead{Alarm Reset} \\t& On/Of +f \\t\\\\ \\hline \\n 3 - Alarms - Alarms' }; $VAR5 = 'Flow Diagram'; $VAR6 = { '0' => 3, '1' => '\\mytabhead{Flow Diagram} \\t& \\mytabhead{Sequence + Advance} \\t& Momentary \\t\\\\ \\hline \\n 1 - Flow Diagram - Alarm +s' '2' => '\\t \\t \\t \\t& \\mytabhead{Sequence Hold} \\t& Mom +entary \\t\\\\ \\hline \\n 2 - Flow Diagram - Flow Diagram' '3' => '\\t \\t \\t \\t& \\mytabhead{Sanitize Enable/Disable +} \\t& On/Off \\t\\\\ \\hline \\n 3 - Flow Diagram - Flow Diagram' };


From here my thought was to use the button count ($hash{ScreenName}{0}) for each button to fill in the number on the .tex file (\multirow{???}) and count up to the Button count while also tracking buttons per page and somehow splitting the remaining and putting on the next page.


I know now I'm in way over my head lol please help me get further in this task. I don't want to have to do this manually in a word document. Thanks you for any help.

Mel


In reply to Hash Manipulation by JusaEngineer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.