473,465 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Little problem with Perl

3 New Member
I made a script this copy a line from my PHP page.
now I did this one:

Expand|Select|Wrap|Line Numbers
  1. while($Res=~m/<br>uptime:(.+?)\<br>/g){
  2. $uptime=$1;
  3. }
  4.  
its search for text start with: " uptime: "
then get the text what after this

The result needs to be something like:
Expand|Select|Wrap|Line Numbers
  1. 03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23
but when I try to do this:
Expand|Select|Wrap|Line Numbers
  1. print "$uptime<br>"
the result is:
Expand|Select|Wrap|Line Numbers
  1. 03:29:14 up 12 days
How can I fix it? (I want this will read only this line)


Thanks, tripc.
Sep 24 '07 #1
7 1125
numberwhun
3,509 Recognized Expert Moderator Specialist
I made a script this copy a line from my PHP page.
now I did this one:
while($Res=~m/<br>uptime:(.+?)\<br>/g){
$uptime=$1;
}

its search for text start with: " uptime: "
then get the text what after this

The result needs to be something like:
03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23

but when I try to do this:
print "$uptime<br>"

the result is:
03:29:14 up 12 days

How can I fix it? (I want this will read only this line)


Thanks, tripc.
You have posted your question under Perl Articles instead of the Perl Forum.
I have moved it across for you.

Please be sure to confine your questions to the Perl Forum in the future!

- MODERATOR
Sep 24 '07 #2
numberwhun
3,509 Recognized Expert Moderator Specialist
I made a script this copy a line from my PHP page.
now I did this one:

Expand|Select|Wrap|Line Numbers
  1. while($Res=~m/<br>uptime:(.+?)\<br>/g){
  2. $uptime=$1;
  3. }
  4.  
its search for text start with: " uptime: "
then get the text what after this

The result needs to be something like:
03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23

but when I try to do this:
print "$uptime<br>"

the result is:
03:29:14 up 12 days

How can I fix it? (I want this will read only this line)


Thanks, tripc.
It looks like you posted this same questions twice. Once to the Perl Articles and once to the Perl Forum. Please be sure and only post your questions to the Perl Forum, and only post them once.

Thank you!

Regards,

Jeff
Sep 24 '07 #3
KevinADC
4,059 Recognized Expert Specialist
I made a script this copy a line from my PHP page.
now I did this one:

Expand|Select|Wrap|Line Numbers
  1. while($Res=~m/<br>uptime:(.+?)\<br>/g){
  2. $uptime=$1;
  3. }
  4.  
its search for text start with: " uptime: "
then get the text what after this

The result needs to be something like:
03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23

but when I try to do this:
print "$uptime<br>"

the result is:
03:29:14 up 12 days

How can I fix it? (I want this will read only this line)


Thanks, tripc.
There is no way to know without seeing the text you are working with.
Sep 24 '07 #4
tripc
3 New Member
I just want this $uptime will show me the result

the line of 'uptime' of my PHP page:
Expand|Select|Wrap|Line Numbers
  1. uptime: 03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23
but when I type $uptime I get this:
Expand|Select|Wrap|Line Numbers
  1. 03:29:14 up 12 days
=\

I think I should do something like:
Expand|Select|Wrap|Line Numbers
  1. while($Res=~m/<br>uptime:(.+?)\,(.+?)\,(.+?)\,(.+?)\,(.+?)\<br>/g){
  2. $uptime=$1.$2.$3.$4.$5;
Sep 24 '07 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
I just want this $uptime will show me the result

the line of 'uptime' of my PHP page:
uptime: 03:29:14 up 12 days, 7:08, 1 user, load average: 0.17, 0.15, 0.23

but when I type $uptime I get this:
03:29:14 up 12 days

=\

I think I should do something like:
while($Res=~m/<br>uptime:(.+?)\,(.+?)\,(.+?)\,(.+?)\,(.+?)\<br >/g){
$uptime=$1.$2.$3.$4.$5;
Instead of showing us how it is displayed on the web page, why not do a "view source" and show us the line that you are trying to match from there? That way, as Kevin said, we can see what you are trying to match.

Regards,

Jeff
Sep 24 '07 #6
tripc
3 New Member
Instead of showing us how it is displayed on the web page, why not do a "view source" and show us the line that you are trying to match from there? That way, as Kevin said, we can see what you are trying to match.

Regards,

Jeff
The commands are:
Expand|Select|Wrap|Line Numbers
  1. $uptime = system(uptime);
  2. echo "uptime: $uptime<br>";
  3. system(uptime);
the result needs to be:
Expand|Select|Wrap|Line Numbers
  1. 15:24:50 up 12 days, 19:04, 1 user, load average: 0.41, 0.51, 0.45
and I use
Expand|Select|Wrap|Line Numbers
  1. while($Res=~m/<br>uptime:(.+?)\<br>/g){
  2. $uptime=$1;
  3. }
Thanks, tripc.
Sep 24 '07 #7
KevinADC
4,059 Recognized Expert Specialist
forget it, I can't help somone that can't follow simple instructions.
Sep 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
by: Greg Lindstrom | last post by:
Hello- I have a task which -- dare I say -- would be easy in <asbestos_undies> Perl </asbestos_undies> but would rather do in Python (our primary language at Novasys). I have a file with...
0
by: Matt Ittigson | last post by:
I'm getting the following error(s) running perlcc and can't find any explanation or work around. I'm including the errors and the script itself. I get the same errors on a cygwin+Win2k box as a...
4
by: Firewalker | last post by:
Hey guys, I am newbie to perl. I am trying to deal with dates ( such trying to find what the date would be after month). Is therea function or date class( I am a java programmer, I couldnt find...
3
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly...
13
by: Otto J. Makela | last post by:
I'm trying to install to php the Perl-1.0.0.tgz package (from http://pecl.php.net/package/perl, enabling one to call perl libraries) to a pre-existing Solaris system. Unfortunately, the attempt...
0
by: OverTheTop | last post by:
All the usual Newbie stuff applies... I have a Windows2000 Server with ActivePerl and a module (DBD-Interbase) that worked fine. Trying to duplicate the environment on Windows2003 Server for...
45
by: Gaijinco | last post by:
Hi my name is Carlos Obregón and I'm currently a profesor of C/C++ programming at the CUMD in Bogotá Colombia. This last term I ask my students to develop an implementation of the minesweeper...
5
by: islayer | last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.