eial has asked for the wisdom of the Perl Monks concerning the following question:

Hi, people i have some question: How i make for exporter a reference and how i make for run some sub rutine when the script finish (something like that unonload, in html) and how work DESTROY becouse i can't use or i not know as use :-( well, again thank for your great help.

Replies are listed 'Best First'.
Re: how to make for exporter reference
by PodMaster (Abbot) on Mar 31, 2004 at 08:14 UTC
    How i make for exporter a reference
    I don't understand (feel free to ask in your native language, perlmonks is international). Maybe you want to read `perldoc Exporter'?
    how i make for run some sub rutine when the script finish(something like that unonload, in html)
    use an END block, ie
    print "hello $/"; END { warn "this is the end"; } print "my friend $/"; __END__ hello my friend this is the end at - line 3.
    See Execution order of END/CHECK vs BEGIN/INIT for more info on that.
    how work DESTROY becouse i can't use or i not know as use
    Heh, read any of

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: how to make for exporter reference
by leriksen (Curate) on Mar 31, 2004 at 08:33 UTC
    How i make for exporter a reference

    Perhaps it would be better to export a function that returns a reference - like this

    package Example; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(make_reference); sub make_reference { ... return \$scalar_thing; # or return \@array_thing; # or return \%hash_thing; # or return \&code_thing; # or return \*glob_thing; # or [], or {} } 1;

    Perl's OO paradigm works like this - constructors return blessed references, binding the reference to a package/module.

    +++++++++++++++++
    #!/usr/bin/perl
    use warnings;use strict;use brain;