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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [stumpd] Trying to sort output: Edit Log

Veteran / Moderator

Feb 23, 2013, 10:07 AM

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

In Reply To

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:

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);

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