CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
array length gets printed instead of array Perl

 



perlwatcher
User

Jul 19, 2010, 1:09 AM

Post #1 of 3 (694 views)
array length gets printed instead of array Perl Can't Post

I was trying to kill a process from the output of the ps -aef | grep <processname>



The following is the output from the command which is assigned to variable $result

my $result =

'[root@genstor ~]# ps -aef | grep radiusd
root 30543 1 0 Jul18 ? 00:00:00 radiusd -d /usr/local/etc/raddb/
root 30554 1 0 Jul18 ? 00:00:00 radiusd -d /usr/local/etc/raddb_2/
root 31059 30986 0 00:06 pts/2 00:00:00

[root@genstor ~]#

';



I was trying to kill the process with id 30554 which is under /usr/local/etc/raddb_2/


When I write a small individual script and try to fetch the PID ( 30554) it works well and good, but when I use the same in my framework



in both the ways I am trying to split the $result variable using split function like follows



my @arr = split /\s+/,$result;





When I print @arr while using the framework I am seeing the value as 5 ( which I believe is the size of the array given the no of new lines )



Can anyone help me in this ?


BillKSmith
Veteran

Jul 19, 2010, 4:31 AM

Post #2 of 3 (689 views)
Re: [perlwatcher] array length gets printed instead of array Perl [In reply to] Can't Post

Nothing wrong here. It sounds like you are printing the array in a scalar context. Use


Code
  

print join( "\n", @arr );

Good Luck,
Bill


rovf
Veteran

Jul 21, 2010, 4:34 AM

Post #3 of 3 (657 views)
Re: [perlwatcher] array length gets printed instead of array Perl [In reply to] Can't Post

Show your print statement.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives