I have to add some easy lines to Perl, and I don't exactly get the regular expressions and how I have to use it. I run a file and get the input from there:
open myFile, "csh ........
I run over the lines of the file output by doing "print", and I see one of the lines is:
TaskID: 1000
(there are plenty of spaces there).
What I want to do, is simply to identify the case were the line begins with TaskID: and then get the number into a variable.
In order to identify the line which begins with TaskID, I did:
if (/TaskID:/) {
my questions:
- The if condition works and it does find when it is the line starts with
TaskID. But is it the correct way to do it, or is there something better? - I don't get how to get the number in this line into a variable.
I tried something like:
my $mytask = $1;
But, it doesn't get it. Can you help me understand how to get the number?