# get process handle by command line name if ( defined( $pargs->{name} ) ) { eval 'use Win32::Process::Info;'; die "Win32::Process::Info is required to get process by name" if $@; $pargs->{name} = lc( $pargs->{name} ); #foreach ( Win32::Process::Info->new( '', 'NT' )->GetProcInfo ) { foreach ( Win32::Process::Info->new( )->GetProcInfo ) { if ( lc( $_->{Name} ) eq $pargs->{name} ) { $pargs->{pid} = $_->{ProcessId}; print "pargs->pid = $pargs->{pid}\n"; last; } } } # get process handle by pid if ( defined( $pargs->{pid} ) ) { my $hProcess = _OpenByPid( $pargs->{pid}, $access ); print "hi 1\n"; $this->{hProcess} = $hProcess if $hProcess; print "hi 2\n"; } return $this; } sub DESTROY { my $this = shift; _CloseProcess( $this->{hProcess} ) if defined $this->{hProcess}; } sub get_memlist { _GetMemoryList( $_[0]->{hProcess} ); } sub get_memtotal { my $this = shift; print "hi 3\n"; my %memlist = $this->get_memlist; print "hi 4\n"; my $sum = 0; $sum += $_ foreach values %memlist; return $sum; }