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: Beginner: Re: [stumpd] Trying to sort output: Edit Log



Laurent_R
Veteran / Moderator

Feb 23, 2013, 10:07 AM


Views: 1581
Re: [stumpd] Trying to sort output


In Reply To

Code
if (@output gt $string) {



I am not sure of what you are trying to do here, but it is very unlikely to do what you want. You are comparing "ASCIIbetically" a string and an array, which doesn't make much sense to me, amthough I don't really know what tyhe content of the @output array is.

In addition, from what I can gather in your post, your unix command is probably not correct, because the grep will usually not filter the right line.

You don't give enough clear information on what you intend to do, but if you are looking for the number of seconds, it would seem from your sample that looking for an opening parenthesis followed by some digits can give you what you are looking for. So you could possibly read your input with something like this:


Code
my $process_nr; 
while (my $line = <$INPUT>) {
$process_nr = $1 if $line =~ /\s+(\d)+ Backup Storage/;
if ($line =~ /\((\d)+/) {
my $waiting_time = $1;
print "Process $process_nr took $waiting_time seconds to execute.\n" if ($waiting_time > 1001);
}
}

Code
 
EDIT: I had not seen Wickedxter's answer when I posted mine.


(This post was edited by Laurent_R on Feb 23, 2013, 10:08 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Feb 23, 2013, 10:08 AM


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

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