ACME-QuoteDB
view release on metacpan or search on metacpan
lib/ACME/QuoteDB/LoadDB.pm view on Meta::CPAN
# TODO support mult-field simultanous loading
if ($value) {
$self->{record}->{$field} = $value;
}
return $self;
}
sub debug_record {
my ($self) = @_;
print Dumper $self->{record};
return;
}
sub get_record {
my ($self, $field) = @_;
lib/ACME/QuoteDB/LoadDB.pm view on Meta::CPAN
if your file format is set to 'html' or 'custom' you must
define this method to do your parsing in a sub class.
Load from html is not supported because there are too many
ways to represt the data. (same with 'custom')
(see tests for examples - there is a test for loading a 'fortune' file format)
One can subclass ACME::QuoteDB::LoadDB and override dbload,
to do our html parsing
=head2 debug_record
dump record (show what is set on the internal data structure)
e.g. Data::Dumper
=head2 set_record
only needed it one plans to sub-class this module.
otherwise, is transparent in usage.
t/01-load_quotes.t view on Meta::CPAN
# parse from data too
$self->set_record(catg => $self->{category});
$self->set_record(rating => $self->{rating});
# TODO
#$self->set_record({
# catg => $self->{category},
# rating => $self->{rating}
#});
#$self->debug_record;
$self->write_record;
}
}
}
package main;
use File::Basename qw/dirname/;
use File::Spec;
# simple glob pattern accepted
t/01-load_quotes.t view on Meta::CPAN
my ($self, $file) = @_;
open my $source, '<:encoding(utf8)', $file || croak $!;
local $/ = $self->{delim};
my $q = q{};
while (my $line = <$source>){
#$self->debug_record;
$q .= $line;
$q =~ s{\A\s+}{}xsmg;
$q =~ s{\s+\z}{}xsmg;
$q =~ s/\s+$self->{delim}//g;
$self->set_record(quote => $q);
my $name = $self->get_record('quote');
$name =~ s{\A(.*?):.*}{$1}xmsg; # not accurate,
t/data/python_quotes.txt view on Meta::CPAN
I mean, just take a look at Joe Strout's brilliant little "python for
beginners" page. Replace all print-statements with sys.stdout.write(
string.join(map(str, args)) + "\n") and you surely won't get any new beginners.
And That Would Be A Very Bad Thing.
-- Fredrik Lundh, 27 Aug 1996
Ya, ya, ya, except ... if I were built out of KSR chips, I'd be running at 25
or 50 MHz, and would be wrong about ALMOST EVERYTHING almost ALL THE TIME just
due to being a computer! Think about it -- when's the last time you spent 20
hours straight debugging your son/wife/friend/neighbor/dog/ferret/snake? And
they *still* fell over anyway? Except in a direction you've never seen before
each time you try it? The easiest way to tell you're dealing with a computer is
when the other side keeps making the same moronic misteakes over and misteakes
over and misteakes over and misteakes over and misteakes over and misteakes
CTRL-C again.
-- Tim Peters, 30 Apr 1997
BTW, a member of the ANSI C committee once told me that the only thing rand is
used for in C code is to decide whether to pick up the axe or throw the dwarf,
and if that's true I guess "the typical libc rand" is adequate for all but the
t/data/python_quotes.txt view on Meta::CPAN
every day <wink>).
-- Tim Peters, 21 Feb 1999
Yes: the code in ntpath.split is too clever to have any hope of working
correctly <wink>.
-- Tim Peters, 19 Mar 1999
Thanks. The sooner I get discouraged and quit, the more time I'll save overall.
-- Frank Sergeant, 28 Mar 1999
But it's a general way to debug: tell someone what right things your program is
doing. Chances are that you will see the wrong thing(s) before the other person
has said anything... I just stick a picture of a face on my monitor and talk to
it to find bugs.
-- Richard van de Stadt, 9 Apr 1999
Might just be nostalgia, but I think I would give an arm or two to get that
(not necessarily my own, though).
-- Fredrik Lundh, 13 May 1999
1. Beautiful is better than ugly.
t/data/python_quotes.txt view on Meta::CPAN
The comp.lang.python newsgroup erupted last week with a flurry of posts that
accused the Python development team of creeping featurism, selling out the
language to corporate interests, moving too fast, and turning a deaf ear to the
Python community. What triggered this lava flow of accusations? The development
team accepted a proposal to change the syntax of the print statement.
-- Stephen Figgins, 30 Aug 2000
INTERVIEWER: Tell us how you came to be drawn into the world of pragmas.
COMPILER WRITER: Well, it started off with little things. Just a few
boolean flags, a way to turn asserts on and off, debug output, that sort of
thing. I thought, what harm can it do? It's not like I'm doing anything you
couldn't do with command line switches, right? Then it got a little bit
heavier, integer values for optimisation levels, even the odd string or two.
Before I knew it I was doing the real hard stuff, constant expressions,
conditionals, the whole shooting box. Then one day when I put in a hook for
making arbitrary calls into the interpreter, that was when I finally realised I
had a problem...
-- Greg Ewing, 31 Aug 2000
The modules people have built for Python are like the roads the Romans built
t/data/www.amk.ca/quotations/python-quotes/page-2.html view on Meta::CPAN
<p class='quotation' id='q42'>I mean, just take a look at Joe
Strout's brilliant little "python for beginners" page. Replace all
print-statements with <code>sys.stdout.write( string.join(map(str,
args)) + "\n")</code> and you surely won't get any new beginners.
And That Would Be A Very Bad Thing.</p>
<p class='source'>Fredrik Lundh, 27 Aug 1996</p>
<p class='quotation' id='q43'>Ya, ya, ya, except ... if I were
built out of KSR chips, I'd be running at 25 or 50 MHz, and would
be wrong about ALMOST EVERYTHING almost ALL THE TIME just due to
being a computer! Think about it -- when's the last time you spent
20 hours straight debugging your
son/wife/friend/neighbor/dog/ferret/snake? And they <em>still</em>
fell over anyway? Except in a direction you've never seen before
each time you try it? The easiest way to tell you're dealing with a
computer is when the other side keeps making the same moronic
misteakes over and misteakes over and misteakes over and misteakes
over and misteakes over and misteakes CTRL-C again.</p>
<p class='source'>Tim Peters, 30 Apr 1997</p>
<p class='quotation' id='q44'>BTW, a member of the ANSI C committee
once told me that the only thing rand is used for in C code is to
decide whether to pick up the axe or throw the dwarf, and if that's
( run in 1.276 second using v1.01-cache-2.11-cpan-49f99fa48dc )