Skip to content

Instantly share code, notes, and snippets.

@JEEN
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save JEEN/10343986 to your computer and use it in GitHub Desktop.

Select an option

Save JEEN/10343986 to your computer and use it in GitHub Desktop.
dear-yim
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