I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2006-12-08 17:57:29-08 by gaetan in response to 3734
Re: OIO and default value
Yeap, it it 6:50pm in France. I will have to leave my office in a few minutes

OK, the previous code is working, but when applying your "recipe" for my program, it does not work

If you add some lines in the code, the program fails

#!/usr/bin/perl use strict; use warnings; package Connection; { use Object::InsideOut; my @bidule :Field :Set(name => 'set_bidule', restricted => 1); my @truc # here the 3 added lines :Field :Arg(name => "truc"); sub init :Init { my ($self, $args) = @_; # Set default, if needed if (! exists($args->{'bidule'})) { $args->{'bidule'} = 0; } # Store value $self->set(\@bidule, $args->{'bidule'}); } sub print_information { my $obj = shift; print "Bidule: $bidule[$$obj]\n"; } } package Connection::Simulate; { use Object::InsideOut('Connection'); sub pre :PreInit { my ($self, $args) = @_; # Set default, if needed if (! exists($args->{'bidule'})) { $args->{'bidule'} = 1; } } } package main; my $sim = Connection::Simulate->new(); $sim->print_information(); my $con = Connection->new(); $con->print_information(); print("Done\n"); exit(0); # EOF
I obtain the following result:
{go}606: perl ~/tmp/toto.pl Bidule: 0 Bidule: 0 Done

I need help (only for next Monday ;-))

Gaetan
Direct Responses: 3738 | Write a response