The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares?
#!perl # # Object: # To output a tab separated list of PID, username and process # for windows XP # # Prerequisites: # 1) ActiveState Perl # 2) Windows XP use warnings; use strict; for my $line (`tasklist /v /nh`) { chomp($line); if ( $line ne "" ) { # extract PID my $pid = substr($line, 26, 6); # remove leading spaces $pid =~ s/^ *([0-9]+)$/$1/g; # extract username my $user = substr($line, 88, 50); # remove trailing spaces $user =~ s/^(.*\S)\s+$/$1/g; # change spaces in username to underscores $user =~ s/\s/\_/g; # extract process my $proc = substr($line, 0, 24).substr($line, 152, 72); # change multiple spaces to single spaces $proc =~ s/\s\s\s*/ /g; # remove trailing space $proc =~ s/\s$//g; # remove trailing N/A $proc =~ s/ N\/A$//g; # print tab seperated fields print $pid, " ", $user, " ", $proc, "\n"; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>