##
sub render {
my $self = shift;
my $tt = $self->engine;
$tt->process($self->template, { $self->template_vars }, \my $output)
or die $tt->error; # passes Template::Exception upward
$self->display($output);
}
sub template_vars {
my $self = shift;
my $self_object = $self->reflect->object; # in case we have a classname
return ( self => $self_object );
}
##
##
sub template_vars {
my $self = shift;
return ( $self->SUPER::template_vars, foo => 'bar' );
}
##
##
# Super/Module.pm
{
package Super::Module;
sub foo {
print __PACKAGE__ . ': ' . __LINE__ . "\n";
}
}
1;
__END__
# Some/Module.pm
package Some::Module;
use Super::Module;
our $VERSION = '0.1';
our @ISA = qw( Super::Module );
package Some::Module::YeWhoEnters;
*Some::Module::YeWhoEnters =
*Some::Module::YeWhoEnters = \@Super::Module::ISA;
sub Some::Module::foo {
my $class = shift;
$class->SUPER::foo();
print __PACKAGE__ . ': ' . __LINE__ . "\n";
}
1;
__END__
# test.pl
use strict;
use warnings;
use Some::Module;
Some::Module->foo();
__END__
Can't locate object method "foo" via package "Some::Module::YeWhoEnters" at Some/Module.pm line 15.
##
##
sub foo {
my $hashref = shift;
while ( my ( $key, $value ) = each %$hashref ) {
return if sometest( $key );
frobnicate( $key, $value );
}
}
##
##
+++ - Thu Nov 10 21:32:08 2005
@@ -536,7 +536,7 @@
sub _print_and_exit {
my ($pod, $paged) = @_;
- if (-t *STDOUT and eval { require POD::Text }) {
+ if (-t *STDOUT and eval { require Pod::Text }) {
if ($paged) {
eval { require IO::Page } or eval { require IO::Pager::Page };
}
@@ -1218,11 +1218,11 @@
This argument cause the program to print the complete POD documentation
for the program and exit. If the standard output stream is connected to
-a terminal and the POD::Text module is available, the POD is formatted
+a terminal and the Pod::Text module is available, the POD is formatted
before printing. If the IO::Page or IO::Pager::Page module is available,
the formatted documentation is then paged.
-If standard output is not connected to a terminal or POD::Text is not
+If standard output is not connected to a terminal or Pod::Text is not
available, the POD is not formatted.
=item --version
Welcome, ladies and gentlemen, to The Perl Gallery.
This evening we take look at the unholy mix of [doc://map] and [doc://return].
Let's begin with the argument-less form of return. How often have we seen a routine that ends in a plain return;? "Oh, that just returns undef." Really? Consider this:
sub nasty {
if ( $_[ 0 ] % 3 ) {
return $_[ 0 ];
}
else {
return;
}
}
my @x = map nasty( $_ ), 1..10;
Quick, how many elements in @x? 7 or 10?
##
##
create table foo (
id serial,
name varchar(60) not null,
constraint foo_pk primary key(id),
constraint foo_name unique(name)
);
create table bar (
id serial,
foo_id integer not null references foo (id),
name varchar(500) not null,
constraint bar_pk primary key(id)
);
##
##
insert into foo(name) values('Mumble Frotz');