usrlocal has asked for the wisdom of the Perl Monks concerning the following question:
However owing to the fact that strict refs is enforced throughout the perl script, I get the error: Error Converting from string to SCALAR in line 325 . that line runs as below:$processor = `/aa/bin/get_bind_cpus.ksh`
This processor variable is also populated at anbother location (where the script tries to find similar processes using the same processor and bind to that) as illustrated by the code sample below:my $mgr = shift; my $processor = shift; my $proc_id = locate_process_id( $mgr ); foreach ( keys %{$proc_id} ) { next unless defined $$proc_id{$_}; system("$os_command_table{$^O}{pbind} -b $$processor $ +$proc_id{$_} >/dev/null 2>&1") if defined $$processor; } } }
My simple question is how should the line of code I am trying to introduce:sub get_cpu_used_by_other_proc { my $other_mgr = shift; my $proc_id = locate_process_id( $other_mgr ); my $processor = undef; my $pid = undef; my @cmd_output = `$os_command_table{$^O}{pbind} -q 2>/dev/null +`; die "ERROR:failed to retrieve the bound processors\n" unless ( + $? == 0 ); ##### increase the weight of processors based on used or not # +#### foreach ( keys %{$proc_id} ) { $pid = $$proc_id{$_}; next unless defined $pid; foreach ( @cmd_output ) { $processor = $1, return \$processor if /proces +s\s+id\s+${pid}\s*:\s*(\d+)$/; } } }
be modified so that it populates the processor scalar correctly so that it dosent bomb onthe call to pbind:$processor = `/aa/bin/get_bind_cpus.ksh`
Help is appreciatedsystem("$os_command_table{$^O}{pbind} -b $$processor $ $proc_id{$_} >/dev/null 2>&1")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting from string to SCALAR when using strict "refs"
by kyle (Abbot) on Jan 21, 2009 at 21:21 UTC | |
|
Re: Converting from string to SCALAR when using strict "refs"
by kennethk (Abbot) on Jan 21, 2009 at 21:26 UTC | |
by usrlocal (Novice) on Jan 26, 2009 at 22:20 UTC |