I modified printConfig and printList as follows and things are working now without the write format.
sub printList { my $self = shift; my $fh = shift; foreach my $struct (values %{$self->list}) { $type = $struct->type; $name = $struct->name; $action = $struct->hu; if ( $struct->type =~ /LIGHT|FAN|CAMERA|CHRISTMAS/ ) { printf($fh " %s %-22s %s\n", $struct->type, +$struct->name,$struct->hu); } if ( $struct->type =~ /ZONE/ ) { printf($fh "ZONE %-22s %s\n", $struct->na +me,$struct->hu); printf $fh " SECURITY %-22s %s\n", $struct->na +me,$struct->security; printf $fh " STATE %-22s %s\n", $struct->na +me,$struct->state; printf $fh " BATTERY %-22s %s\n", $struct->na +me,$struct->battery; &printList($struct,$fh); } if ( $struct->type =~ /GROUP/ ) { printf($fh " GROUP %-22s %s\n", $struct->na +me,$struct->hu); printf $fh " SECURITY %-22s %s\n", $struct->na +me,$struct->security; printf $fh " STATE %-22s %s\n", $struct->na +me,$struct->state; printf $fh " BATTERY %-22s %s\n", $struct->na +me,$struct->battery; &printList($struct,$fh); } if ( $struct->type =~ /AREA/ ) { printf($fh " AREA %-22s %s\n", $struct->na +me,$struct->hu); printf $fh " SECURITY %-22s %s\n", $struct->na +me,$struct->security; printf $fh " STATE %-22s %s\n", $struct->na +me,$struct->state; printf $fh " BATTERY %-22s %s\n", $struct->na +me,$struct->battery; &printList($struct,$fh); } } } sub printConfig { my $configfile = shift; my $house = shift; my $space = ""; open(my $fh, ">$configfile"); printf($fh "ZONE %-22s %s\n", $house->name,$house +->hu); printf $fh " SECURITY %-22s %s\n", $house->name,$house +->security; printf $fh " STATE %-22s %s\n", $house->name,$house +->state; printf $fh " BATTERY %-22s %s\n", $house->name,$house +->battery; &printList($house,$fh,$house->type); close($fh); }
The Config file now prints the way I wanted. I am sure there is a more compact way to do it though.
ZONE Master G1 SECURITY Master OFF STATE Master OFF BATTERY Master 20180410 ZONE Outdoor G2 SECURITY Outdoor OFF STATE Outdoor OFF BATTERY Outdoor 20180410 GROUP Frontdoor G5 SECURITY Frontdoor OFF STATE Frontdoor OFF BATTERY Frontdoor 20180410 GROUP Deck G6 SECURITY Deck OFF STATE Deck OFF BATTERY Deck 20180410 GROUP Basement G7 SECURITY Basement OFF STATE Basement OFF BATTERY Basement 20180410 ZONE Indoor G3 SECURITY Indoor OFF STATE Indoor OFF BATTERY Indoor 20180410 GROUP SecondFloor G10 SECURITY SecondFloor OFF STATE SecondFloor OFF BATTERY SecondFloor 20180410 GROUP FirstFloor G9 SECURITY FirstFloor OFF STATE FirstFloor OFF BATTERY FirstFloor 20180410 AREA Livingroom G14 SECURITY Livingroom OFF STATE Livingroom OFF BATTERY Livingroom 20180410 AREA EntryWay G13 SECURITY EntryWay OFF STATE EntryWay OFF BATTERY EntryWay 20180410 LIGHT Entryway Light N1 GROUP Basement G11 SECURITY Basement OFF STATE Basement OFF BATTERY Basement 20180410 GROUP Attic G8 SECURITY Attic OFF STATE Attic OFF BATTERY Attic 20180410 ZONE Garage G4 SECURITY Garage OFF STATE Garage OFF BATTERY Garage 20180410

In reply to Re^2: write command failing by cmora111
in thread write command failing by cmora111

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.