Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: write command failing

by huck (Prior)
on May 09, 2018 at 03:56 UTC ( [id://1214254]=note: print w/replies, xml ) Need Help??


in reply to Re^2: write command failing
in thread write command failing

my $f0="%-22s %s\n"; my $f1='%-22s' .$f0; my $f2=' %-18s' .$f0; my $f3=' %-14s' .$f0; my $f4=' %-10s' .$f0; sub printList { my $self = shift; my $fh = shift; foreach my $struct (sort values %{$self->list}) { my $type = $struct->type; if ( $type =~ /LIGHT|FAN|CAMERA|CHRISTMAS/ ) { printf $fh $f4, $type,$struct->name,$struct->hu; } else{ my ($ftop,$fline); if ( $type =~ /ZONE/ ) { $ftop=$f1; $fline=$f2;} if ( $type =~ /GROUP/ ) { $ftop=$f2; $fline=$f3;} if ( $type =~ /AREA/ ) { $ftop=$f3; $fline=$f4;} printSet($struct,$fh,$ftop,$fline); printList($struct,$fh); } } } sub printSet { my $struct=shift; my $fh=shift; my $ftop=shift; my $fline=shift; $name = $struct->name; printf $fh $ftop, $struct->type,$name,$struct->hu; for my $method (qw/security state battery/) { printf $fh $fline,uc($ +method),$name,$struct->$method; } } sub printConfig { my $configfile = shift; my $house = shift; my $space = ""; open(my $fh, ">$configfile"); printSet($house,$fh,$f1,$f2); printList($house,$fh,$house->type); close($fh); }
Of most interest here is that "methods" are nothing but string literals.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-24 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found