package Twitter::Objects;
use strict;
use warnings;
use lib '..';
use Base::Data qw(data_file get_hash);
my %accounts = get_hash(
file => data_file('Twitter','account_totals.txt'),
headings => [qw(screen_name followers friends updates)],
);
sub new {
my $self = \%accounts;
bless($self);
return $self;
}
1;
####
package Twitter::Objects;
use strict;
use warnings;
use lib '..';
use Base::Data qw(data_file get_hash);
my %accounts = get_hash(
file => data_file('Twitter','account_totals.txt'),
headings => [qw(screen_name followers friends updates)],
);
sub new {
my ($account) = @_;
my $self = \%{$accounts{$account}};
bless($self);
return $self;
}
1;
##
##
sub get_hash {
my %opt = @_;
open(my $fh, '<', $opt{file}) or die("can't open $opt{file} $!");
my $line_number = 0;
my %hash;
while (my $line = <$fh>) {
++$line_number;
chomp $line;
my @values = split(/\|/,$line);
my $n = 0;
$hash{$values[0]}{sort_number} = $line_number if $opt{sort};
for my $heading (@{$opt{headings}}) {
$hash{$values[0]}{$heading} = defined($values[$n]) ? $values[$n] : '';
++$n;
}
}
return %hash;
}