The Number in the ()? In This Case 1?
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
I would personally use split..... if you know that the line will look like that most of the time, it's easy enough to split it like so:
($junk, $rest) = split(/\(/, $_); # $_, or whatever variable contains the string
push @numarray, substr($rest, 0, 1);
Now, the array numarray will contain those numbers.... and you can do a:
foreach $num (@numarray) {
print "$num\n";
}
Or Reference The Array in Scalar context, such as $numarray[0]. Let me know how that works for you.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Sure, but you should only need 1 set of parenthesis, and you might have to escape them, I'm not sure... (by escaping, I mean making it a literal character using \, such as \(, but I'm not positive you have to). But you have the idea straight up.... just search the string for what you are looking for, and then run the split if it's true. You could also look at using your own custom function, but I think you hit the nail on the head with the pattern matching regex above.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
;) leaning toothpick syndrome.... gotta love it
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215