Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching A value

Status
Not open for further replies.

inforeqd

Technical User
Jan 8, 2001
95
US
Hopefully this is simple, but once again my expression matching is getting the best of me.

The setup is a java applet that uses POST to submit a
value to my cgi/perl script.

The submit is doing this when I run ethereal against it

sliderVal=-8.00 .. This is correct since I'm using a slider to have the user submit the value. However all I need is an expression statement to only get the -8.00 out of the POST.

I've tried things like this.. it all works up to the
my line

$chng=<STDIN>;
chomp $chng;
my($new_chng) = $chng =~ /(\d\d\d+)/;

But as you can see that isnt getting the -8.00 value, please note that the -8.00 is only an example. I have it setup to take from -8.00 to 8.00 in increments on .01.

Anyhelp would be great and once again ..thanks in advance
info
 
Give this a try:

Code:
$chng =~ /sliderVal\s*=\s*(-?[\d\.]+)/;
my $new_chng = $1;
 
Michael

Thank you thank you .. that did just the trick.

Is there a site on the internet that better explains all these settings and how one could employ them. I know that this type of functionality is one of perls stronger points and the more and more I use perl the more I'm needed to do these things.

Also, while I have you .. I was wrong on my response. I need to send via the cgi script instead of -8.00 just an -800, so I need to chop out the decimal .. ideas on that?? What you posted worked exactly the way that I asked about. Again thanks.

thanks again
info
 
remove the \. in michael's post

should be enough on the current.

perldoc perlre from your command line should give you a good start on regex (regular expressions)

hth
--paul


cigless ...
 
Code:
$chng=<STDIN>;
chomp $chng;
my($new_chng) = $chng;
$new_chng =~ s/^.*sliderVal\s*\=\s*([\+\-0-9]+)\.([0-9]+).*$/$1$2/;

$1 contains what is in the first set of parens and $2 has what is in the second set of paren.


Michael Libeson
 
Michael

Again, thanks! That did the trick.

info
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top