Hi Perlmonks,
I'm Patrick, this is my first post.
Here is my situation:
I have a txt file where I'm trying to extract "Significant Accounting Policies" (SAP) from a 10k. There usually is a number to the left of SAP.
I would like to take that number and make it a variable then add 1 to that variable to identify the following section so then I can end the collection of the SAP. For example, if the number in front of SAP is 3, I would extract 3, create a variable, add 1, and my new variable would be 4. The code would then identify that the following section is section 4 and I can end my extraction at the beginning of section 4.
Here is an example:
(1) Summary of Significant Accounting Policies
Revenue Recognition
Revenue is recognized at the time goods are sold and shipped.
(2) Long-term Debt
****
the number in front of SAP is not always the number 1 and the following item is not always long-term debt.
#!/usr/bin/perl -w #use strict; # This program extracts data from an SEC filing, including chunks of t +ext use Benchmark; #get the HTML-Format package from the package manager. use HTML::Formatter; #get the HTML-TREE from the package manager use HTML::TreeBuilder; use HTML::FormatText; $startTime = new Benchmark; #This program is written to obtain "Significant Accounting Policies" w +hich are typically found in item 4/4 of the 10k my $startstring='((^\s*?)Significant Accounting Policies\s\n)'; #Specify keywords/phrases you expect to find within the item (make sur +e the words phrases are not also in the start or end string) my $keywords='(estimates|Financial Accounting Standards Board|Reven +ue Recognition|generally accepted accounting principles|accruals|inve +ntories|straight-line|)'; #horizontal line means alternative match if + not found #Specify the end of the text you are looking for. # Need to create a flexible end string that uses +1 the variable in fr +ont of "SAP" my $endstring='((^\s*?)Item\s+(10)[\.\-]?[^\d]*?\n)'; my $direct="D:\\ExternalFiles\\Edgar\\tenks\\randomsort";
In reply to Making a variable from a number in front of a string by porsche5k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |