LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   perl regular expression:: take decimal out of statement. (https://www.linuxquestions.org/questions/linux-newbie-8/perl-regular-expression-take-decimal-out-of-statement-815708/)

knockout_artist 06-22-2010 12:45 PM

perl regular expression:: take decimal out of statement.
 
Hi,


If I have this

Code:

something(92)
And I want to process 92(that number would change on every reading cycle) from above statement how do I do it?

Thank

smeezekitty 06-22-2010 12:48 PM

More details?
Define process.

knockout_artist 06-22-2010 01:01 PM

Code:


  1 #!/usr/bin/perl
  2
  3 $out = "/tmp/file";
  4
  5 open FILE, $out or die $!;
  6 while(<FILE>){
  7
  8 if ($_ =~ m/something\(/ ) {    // this matches just fine
  9 print "$_\n\n";
 10
 11  $test= ($_=~ m/(\d+)/){      // now I need to to know what number something() contains.
 12
 13
 14
 15 print "$test \n\n";
 16 }
 17
 18
 19 }}

out file is:
Code:


Copyright IBM Corp. 1994, 2008.  ALL RIGHTS RESERVED.
stuff    more stuff  .


    1 : stuff 
stuff details.
  stuff one                   
 something(0)






Thanks

knockout_artist 06-23-2010 09:30 AM

Really?

Was it that hard? come on people.

knockout_artist 06-23-2010 02:17 PM

Code:


 if($_ =~ m/(\d+)/){
 
 print "ok here is the thing:  $1\n";
 }



Thanks.


All times are GMT -5. The time now is 05:42 AM.