Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format 1

Status
Not open for further replies.

nix45

MIS
Nov 21, 2002
478
US
I'm having a trouble getting a table to print out correctly. Only the first line looks right, $hostname. After that, it just prints exactly as shown without interpolating the variables and actually prints the single quotes and commas I put around the words before it. Why is it only printing the first line? I've tried different combinations but nothing seems to work.
Code:
#!/usr/bin/perl -w

$hostname = 'tux.foo.org';
$os = 'RHEL30';
$date = '7/27/04';
$ip = '192.168.0.2';
$mask = '255.255.255.0';
$gw = '192.168.0.1';
$dns = '192.168.0.10, 192.168.0.20';
$mac = '00:0D:56:C7:59:71';
$cpu = 'Intel(R) Celeron(R) CPU 2.20GHz';
$ram_mb = '256Mb';

format STDOUT_TOP =
                         $hostname info
------------------------------------------------------------------
.
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Hostname:',            $hostname
'OS Version:',          $os
'Date:',                $date
'IP Address:',          $ip
'Subnet Mask:',         $mask
'Gateway:',             $gw
'DNS Servers:',         $dns
'MAC_Address:',         $mac
'CPU:',                 $cpu
'Memory:',              $ram_mb
.
write;
Thanks,
Chris
 
I found that everything works if I do this below, but this is ugly and there has to be a better way?
Code:
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Hostname:',            $hostname
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'OS Version:',          $os
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Date:',                $date
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'IP Address:',          $ip
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Subnet Mask:',         $mask
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Gateway:',             $gw
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'DNS Servers:',         $dns
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'MAC_Address:',         $mac
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'CPU:',                 $cpu
@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<
'Memory:',              $ram_mb
Chris
 
Code:
[b]#!/usr/bin/perl[/b]

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$left                $right
.

$hostname = 'tux.foo.org';                     print_me_pretty('Hostname',    $hostname);
$os       = 'RHEL30';                          print_me_pretty('OS Version',  $os);
$date     = '7/27/04';                         print_me_pretty('Date',        $date);
$ip       = '192.168.0.2';                     print_me_pretty('IP Address',  $ip);
$mask     = '255.255.255.0';                   print_me_pretty('Subnet Mask', $mask);
$gw       = '192.168.0.1';                     print_me_pretty('Gateway',     $gw);
$dns      = '192.168.0.10, 192.168.0.20';      print_me_pretty('DNS Servers', $dns);
$mac      = '00:0D:56:C7:59:71';               print_me_pretty('MAC_Address', $mac);
$cpu      = 'Intel(R) Celeron(R) CPU 2.20GHz'; print_me_pretty('CPU',         $cpu);
$ram_mb   = '256Mb';                           print_me_pretty('Memory',      $ram_mb);

sub print_me_pretty {

  $left = shift;
  $right = shift;

  write;

}


Kind Regards
Duncan
 
no problem nix45 - thanks for the vote of approval!

... an interesting problem!


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top