Well, this works too, if you really want to go through Exporter. I don't think you're going to be able to use as you would if the package were in a separate file since use really implies other fileness.

use strict; use warnings; use Test::More 'no_plan'; package my_temp_convert; require Exporter; our @ISA = ('Exporter'); our @EXPORT = qw(set_temp set_scale c f); my $curr_scale=0; #centigrade, 1=faren my $cur_ctemp=0; sub set_scale{ $curr_scale=shift} sub set_temp{ $cur_ctemp =shift} sub c {return $cur_ctemp;} sub f {return 32+(9*$cur_ctemp)/5} package main; Exporter::import( 'my_temp_convert' ); set_scale(1); set_temp(0); is( f(), 32, 'f() returns 32' ); is( c(), 0, 'c() returns 0' );

In reply to Re^3: multiple "sub" packages in 1 file: possible? how? by kyle
in thread multiple "sub" packages in 1 file: possible? how? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.