sub showAvman(){ $dbh = DBI->connect ("dbi:Pg:dbname=NPMS"); $res=$dbh->prepare("select \"name\", \"address\", \"type\", \"pollint\", \"protocol\" from \"avman\" order by \"name\""); $res->execute; format STDOUT_TOP= Name IP Address Type Pollint Pr +otocol . format STDOUT= @<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @ +<<<<<<<<<<<< $row->{name}, $row->{address},$row->{type} ,$row->{pollint},$r +ow->{protocol} . while ($row=$res->fetchrow_hashref()){ Name IP Address Type Pollint Pr +otocol . format STDOUT= @<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @ +<<<<<<<<<<<< $row->{name}, $row->{address},$row->{type} ,$row->{pollint},$r +ow->{protocol} . while ($row=$res->fetchrow_hashref()){ if ($row->{type} eq "SNMP"){ @_=split(/:/,$row->{protocol}); $row->{protocol} = "Interface $_[1]"; } \"address\", \"type\", \"pollint\", \"protocol\" from \"avman\" order by \"name\""); $res->execute; format STDOUT_TOP= Name IP Address Type Pollint Pr +otocol . format STDOUT= @<<<<<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @ +<<<<<<<<<<<< $row->{name}, $row->{address},$row->{type} ,$row->{pollint},$r +ow->{protocol} . while ($row=$res->fetchrow_hashref()){ if ($row->{type} eq "SNMP"){ @_=split(/:/,$row->{protocol}); $row->{protocol} = "Interface $_[1]"; } write STDOUT; } $res->finish; $dbh->disconnect; } sub showEvents(){ $var=NPMS::getGlobals(); $maxEvent=$var->{maxevent}; $dbh = DBI->connect ("dbi:Pg:dbname=NPMS"); $res=$dbh->prepare("select t.\"status\", to_char(l.\"time\",\'Dy DD Mon YYYY HH12:MI am\') as t +ime, l.\"extra_text\", t.\"desc\", l.\"userid\", l.\"device\", l.\"number\" from \"events\" t, \"event_log\" l where t.\"id\" = l.\"id\" and l.\"ack\" = \'0\' order by \"number\" DESC limit $maxEvent"); if (!defined $res){ die "Cannot prepare statement\n"; } $res->execute; format STDOUT_TOP= STATUS USERID TIME DEVICE DESC . format STDOUT= @<<<<<<<<<<<< @<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< +<<<<< $row->{status},$row->{userid},$row->{device},$row->{desc} . while ($row=$res->fetchrow_hashref()){ write STDOUT; # print "......$row->{status}......$row->{userid}......$row->{de +vice}......$row->{desc}\n"; } $res->finish; $dbh->disconnect; }
Readmore tags added and Formatting fixed by holli
In reply to formatting STDOUT more than once by bahadur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |