Hello!
I have a script that needs some tweaking.
Right now, I have the script grabbing a number of different lines from one file and inserting them into another.
Now what I need is to be able to grab ONLY the last digits and insert them into my file.
Here is an example of what I need to parse:
--------------------------------------------
::= { sonicwallFwTrapRoot 0 2 }
--------------------------------------------
What I need is ONLY the last digit there, just the two, the other stuff I can discard.
Right now the last part of the script (which is what needs to be changed) is setup like this:
--------------------------------------------
my $trapid = '';
if ($record =~ /^\s+::= (\d+)/m) {
$trapid = $1;
} else {
print OUTFILE "Error: Trapid not found in record - $record";
}
--------------------------------------------
What has to be changed so I can have it ONLY grab the last block? Keep in mind, the last block of numbers will change in size, it wont always be a single digit.
In the example above the last block I'm referencing is 2.
Thanks for the help!
I have a script that needs some tweaking.
Right now, I have the script grabbing a number of different lines from one file and inserting them into another.
Now what I need is to be able to grab ONLY the last digits and insert them into my file.
Here is an example of what I need to parse:
--------------------------------------------
::= { sonicwallFwTrapRoot 0 2 }
--------------------------------------------
What I need is ONLY the last digit there, just the two, the other stuff I can discard.
Right now the last part of the script (which is what needs to be changed) is setup like this:
--------------------------------------------
my $trapid = '';
if ($record =~ /^\s+::= (\d+)/m) {
$trapid = $1;
} else {
print OUTFILE "Error: Trapid not found in record - $record";
}
--------------------------------------------
What has to be changed so I can have it ONLY grab the last block? Keep in mind, the last block of numbers will change in size, it wont always be a single digit.
In the example above the last block I'm referencing is 2.
Thanks for the help!