Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Regex to extract number from text file

by premal (Acolyte)
on Feb 18, 2009 at 12:05 UTC ( [id://744724]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex to extract number from text file
in thread Regex to extract number from text file

Thanks for your reply. I tried writing following code but it is not printing anything on screen.

my @temp;
open(FILE,"C:\\test.txt");
@temp = <FILE>;
close(FILE);
foreach (@temp)
{
my $search =~ m/ClearQuest\: \(Total of 18 licenses issued\; Total of (\d+)/;
my $wd = $1;
print "\n$wd\n";
exit;
  • Comment on Re^2: Regex to extract number from text file

Replies are listed 'Best First'.
Re^3: Regex to extract number from text file
by moritz (Cardinal) on Feb 18, 2009 at 12:13 UTC
    That's a bit of surprise to me, because for me it prints
    Missing right curly or square bracket at /home/moritz/foo.pl line 10, +at end of line syntax error at /home/moritz/foo.pl line 10, at EOF Execution of /home/moritz/foo.pl aborted due to compilation errors.

    Please use <code>...</code> tags around code examples that you put here, and also make sure to copy & paste them from your actual script to not introduce some bugs by incorrectly writing it down.

    Also please start your scripts with

    use strict; use warnings;

    And you'll get at least a warning about what you're doing wrong.

Re^3: Regex to extract number from text file
by dxxd116 (Beadle) on Feb 18, 2009 at 13:49 UTC
    You need to change the code:
    my $search =~ m/ClearQuest\: \(Total of 18 licenses issued\; Total of +(\d+)/;
    to:
    (my $search)=$_=~ m/ClearQuest\: \(Total of 18 licenses issued\; Total + of (\d+)/;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://744724]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found