LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-22-2010, 12:45 PM   #1
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Rep: Reputation: 33
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

Last edited by knockout_artist; 06-23-2010 at 10:12 AM.
 
Old 06-22-2010, 12:48 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,227

Rep: Reputation: 170Reputation: 170
More details?
Define process.
 
Old 06-22-2010, 01:01 PM   #3
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
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

Last edited by knockout_artist; 06-22-2010 at 01:04 PM.
 
Old 06-23-2010, 09:30 AM   #4
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Original Poster
Rep: Reputation: 33
Really?

Was it that hard? come on people.
 
Old 06-23-2010, 02:17 PM   #5
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

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


Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression in Perl tarken Programming 11 05-12-2010 08:10 PM
Regular expression doesnt work in an elsif statement? oinker Programming 2 02-04-2010 01:33 PM
regular expression with perl MissEileen Programming 3 03-11-2008 01:26 PM
Perl Regular Expression abdul_zu Linux - Software 2 08-20-2007 03:57 AM
Perl Regular Expression rch Programming 14 07-11-2003 11:00 PM


All times are GMT -5. The time now is 10:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration