I'm new to PERL but I'm picking up quick. I've been able to search a file for a certain string but now I need something slightly different and I'm completely lost.

I need to search a text file for a string and return the text after it.
I have a list of files inside a directory and I'm looking for certain keywords and then I have to find the id of that file. I've found the keywords since I'm looking for a certain word but I don't know how to find the id inside the text file.

I.E.
Text I'm looking for: "string_id(12345)"
I need the number inside those parantheses. I can look for "string_ID(" but I don't know how to find the number inside the parantheses.

Any help would be appreciated. Thanks in adavnce!
Brandon

You could do something like this with regular expressions:

if ($stringToSearch =~ /string_id\((.*?)\)/) {
    print "Found $1\n"
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.