#!/usr/perl/bin use strict; my @words; my @array; my $i = 0; open RI,"C:\\lp.txt") || die "can't open logfile: $!\n"; while() { if (/^printer/) { my @strings = (split)[1,3,4]; if ( $strings[1] eq "idle." ) { push @array, [ "0", 6 ]; } if ( $strings[2] eq "enabled" ) { my $s = "Up"; push @array, [ $s, 5 ]; } push @array, [ $strings[0], 1 ]; } elsif (m|Interface:(.+)|i) { @words = split(/\//, $_); chomp($words[-1]); push @array, [ $words[-1], 3]; } elsif (m|Description: (.+)|i) { push @array, [ $1, 4]; } elsif (m|Connection: (.+)|i) { if ($1 eq "direct" ) { push @array, [ "local", 8]; } else { push @array, [ "remote", 8]; } } elsif (/Banner not required/) { push @array, ["No",7 ]; } if ($i == 3) { for ( sort { $a->[1] <=> $b->[1] } @array ) { print "$_->[0]|"; } @array=(); $i =0; } else { $i++; } }