Last active
August 29, 2015 13:58
-
-
Save JEEN/10343986 to your computer and use it in GitHub Desktop.
dear-yim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| no warnings 'recursion'; | |
| use LWP::Simple; | |
| use Data::Dumper; | |
| use Web::Query::LibXML; | |
| my $text = LWP::Simple::get('http://www.sec.gov/Archives/edgar/data/790730/000079073009000004/0000790730-09-000004.txt'); | |
| my ($html) = $text =~ /(<html>.+<\/html>)/gms; | |
| my @sentences; | |
| wq($html)->find('div>font')->each(sub { | |
| my ($i, $elm) = @_; | |
| my $text = $elm->text; | |
| push @sentences, $text if $text =~ /permanently reinvest/; | |
| }); | |
| my ($vals) = map { my ($amount) = $_ =~ /(\$[0-9,]+)/; [ $amount, $_ ] } grep { /(\$[0-9,]+)/ } @sentences; | |
| my ($amount, $sentence) = @{ $vals }; | |
| print $amount."\n"; # '$94,000,000' | |
| print $sentence."\n"; # 'The Company intends to permanently reinvest its unrepatriated foreign earnings.��The cumulative amount of undistributed earnings of foreign subsidiaries was $94,000,000 at November 30, 2008.��The Company has not provided deferred taxes on the earnings, and the additional U.S. income tax on the unremitted foreign earnings, if repatriated, may be offset in whole or in part by foreign tax credits.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment