Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

State Variables package Trial::Period; sub Perl 5.10 for People Who Aren't Totally Insane

135,754 views

Published on

State Variables
package Trial::Period;
sub new {
my ($class, $arg) = @_;
my $guts = {
lines_left => $arg->{lines},
error_msg => $arg->{error},
};
return bless $guts => $class;
} my $LINES = 100;
my $ERROR = “sorry, trial period over”;
sub consume_line { my $TRIAL = Trial::Period->new({
my ($self) = @_; lines => $LINES,
$self->{lines_left}--; error => $ERROR,
} });

sub lines_left { sub read_line {
my ($self) = @_; $TRIAL->assert_lines_left;
return $self->{lines_left}; ...
} }

sub assert_lines_left {
my ($self) = @_;
unless ($self->lines_left) {
die $self->{error_msg};
}
}
1;




perlsub

Published in: Business, Technology
  • Must see for camel riders
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I have learned a couple of things from your presentation. Nicely done!

    http://www.riding-mower.org/

    http://www.riding-mower.org/la105-john-deere-lawn-tractor/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • The slides showing how awful it can be to have to manage your own inside-out objects are not intended to be a robust explanation of how to force yourself to suffer through it, but an overview of the various levels of annoyance that heap up without fieldhashes.<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Errata: (?)

    Slide 88:
    =======
    Unless you meant to leave $id as an unused variable to resolve in later slides, I'd suggest this change....

    s( $site{$self} )
    ( $site{$id} )gx

    Slide 89:
    =======
    Ditto

    Also, make these changes
    $new should be $new_id
    $old should be $old_id<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Perl 5.10 has been released!
    http://search.cpan.org/~rgarcia/perl-5.10.0/<br /><br/>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

×