in reply to Need help writting a Perl Module

Thanks that was kind of an obvious problem don't know how I could have over looked it... another question I have that I don't quite understand when I need to export information back to the script from the module do I need to give @EXPORT and @EXPORT_OK the name of the variable or the subroutine?

Replies are listed 'Best First'.
Re^2: Need help writting a Perl Module
by Anonyrnous Monk (Hermit) on Dec 08, 2010 at 21:19 UTC
    do I need to give @EXPORT and @EXPORT_OK the name of the variable or the subroutine?

    If I'm understanding you correctly, your question is whether you need to specify the same variable/subroutine in both the @EXPORT and the @EXPORT_OK array (?) If so, no, put it in either one of them.

    @EXPORT_OK is for stuff to be exported upon request, i.e. when the user writes use Module qw(foo); while @EXPORT is for what should be exported by default (without explicit request), i.e. when the user simply says use Module;. If undesired, those default exports have to be disabled by writing use Module (); - note the (empty) list.

    P.S.

    require Exporter; our @ISA = qw(Exporter);

    can also be written as

    use Exporter 'import';

    (see also Re: Advice on style)

Re^2: Need help writting a Perl Module
by BrimBorium (Friar) on Dec 08, 2010 at 21:13 UTC

    Depends on want you want to do ... if you want the subs from your module shared with other scripts export the sube. If you want to share also variables e.g. constants, export the variables. Maybe better declare vars with 'our' then, I'm not sure if this is always necessary.

Re^2: Need help writting a Perl Module
by vendion (Scribe) on Dec 08, 2010 at 21:56 UTC

    Thank you both for answering my question