Hi, I'm totally new to Perl, and I need to get the following: Assuming the output of /usr/bin/uptime is: 17:22 up 2 days, 1 min, 2 users, load averages: 1.65 0.62 0.37

I need a regexp that will get: 2 days, 1 min

Without the last comma, please. I've searched and Googled all afternoon, I have a copy of O'Reilly Learning Perl, but I can't make heads or tails of it. I'm just too new. I need some examples that match what I'm trying to do so I can learn.

Its always good to see what you have tried, even if it does not work. You may have been very close or you may not have, but posting the code you have tried can give an indication of your progress. -------------------------------------------------

The current system date is: Monday, April 13 2009 The current system time is: 00:30 Use of uninitialized value in print at ./up.pl line 10. The system has been up for: The current load average on this machine is: 0.23

I don't know what the possible return values of the uptime application are, I only went by your sample output:

Code

17:22 up 2 days, 1 min, 2 users, load averages: 1.65 0.62 0.37

There is a good chance that could be different depending on the amount of uptime and the regexp will not match if that is the case. For example, what if the uptime where only 3 hours and X minutes, it might look like this:

Code

17:22 up 3 hours, 6 min, 2 users, load averages: 1.65 0.62 0.37

In which case there is no match. You might want to look at the Unix::Uptime module:

It means one of the variables you are printing has no value, here is a very simplified example:

Code

use warnings; $foo = $1; print $foo;

$foo is assigned the value of $1, but since $1 has no value $foo also has no value (uninitialized) and when you try and print an uninitialzed variable the warnings pragma (or the warnings switch on the shebang line) returns the warning you are getting. Basically its letting you know there is something you should check to make sure it will not cause a bigger problem somewhere down the line. You can avoid the warnings by assigning default values:

Code

use warnings; $foo = $1 || 'foo'; print $foo;

Thats just one example of how it could be done. -------------------------------------------------

It means one of the variables you are printing has no value, here is a very simplified example:

Code

use warnings; $foo = $1; print $foo;

$foo is assigned the value of $1, but since $1 has no value $foo also has no value (uninitialized) and when you try and print an uninitialzed variable the warnings pragma (or the warnings switch on the shebang line) returns the warning you are getting. Basically its letting you know there is something you should check to make sure it will not cause a bigger problem somewhere down the line. You can avoid the warnings by assigning default values:

Code

use warnings; $foo = $1 || 'foo'; print $foo;

Thats just one example of how it could be done.

OK, I understand. So much to learn. :-)

I have actually completed my script that this is all releated to, using whatever workarounds I could find.

Ther is a cron job that run when the server is booted that does "echo `date` > up.txt" which is the file I read as UPTXT. You can view the actual web page here: http://bubbabbq.homeunix.net/up_cgi.shtml