On Wed, 2008-09-17 at 16:08 -0400, Aali Naser wrote:
> The code is listed below. I have not figured out how to capture
> multipe disk drive entries.
> Thanks
>
> ===================
> #!perl
# Use strict as well as warnings
use strict;
> use warnings;
>
> my $server;
> my $fcode;
> my $i;
> my $r;
> my $k;
> my $j;
> my $ii;
> my $a;
> my $b;
# Don't use the variables $a or $b, they are used by sort
> my $c;
> my $d;
> my $e;
> my $f;
> my $g;
> my $server_name;
> my $manufac;
> my $model;
> my $num_procs;
> my $mem;
> my $spack;
> my @SLURP_server;
> my $line;
> my $found;
my @device_ids = ();
>
> open(SERVERS, "sample.txt");
# Always check open for errors
open( SERVERS, "sample.txt" ) or die "cannot open sample.txt: $!";
> @SLURP_server=<SERVERS>;
> close (SERVERS);
>
> #####################################################################################
>
> for ($i=0; $i <= $#SLURP_server; $i++) {
> $line=$SLURP_server[$i];
> chomp($line);
>
> if ($line =~ m/^Server Name/) {
> ($a,$server_name)=split(/:/,$line);$i++;
# If you don't need a value assigned in a list of variables, use undef instead
( undef, $server_name ) = split( /:/, $line );
> }
> $line=$SLURP_server[$i];
> chomp($line);
> if ($line =~ m/^Manufacturer/) {
> ($b,$manufac)=split(/:/,$line);$i++;
> }
> $line=$SLURP_server[$i];
> chomp($line);
> if ($line =~ m/^Model/) {
> ($c,$model)=split(/:/,$line);$i++;
> }
> $line=$SLURP_server[$i];
> chomp($line);
> if ($line =~ m/^Number Of Processors/) {
> ($d,$num_procs)=split(/:/,$line);$i++;
> }
> $line=$SLURP_server[$i];
> chomp($line);
> if ($line =~ m/^Mem Total/) {
> ($e,$mem)=split(/:/,$line);$i++;
> }
> $line=$SLURP_server[$i];
> chomp($line);
> if ($line =~ m/^Service Pack/) {
> ($f,$spack)=split(/:/,$line);
$i ++;
> }
while( $line =~ m/^DeviceId/ ){
( undef, my $device_id ) = split( /:/, $line );
$i ++;
push @device_ids, $device_id;
}
> print "$server_name:$manufac:$model:$num_procs:$mem:$spack\n";
print "$server_name:$manufac:$model:$num_procs:$mem:$spack", join( ':',
@device_ids ), "\n";
# Clear the variables so that if any information is missing from the file,
# a warning will be printed
$server_name = $manufac = $model = $num_procs = $mem = $spack = undef;
@device_ids = ();
> }
>
--
Just my 0.00000002 million dollars worth,
Shawn
"Where there's duct tape, there's hope."
Cross Time Cafe
"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/