in reply to Same function multiples unknown modules

You should use do (not use) to load files which don't use package (and they are typically named .pl, not .pm). use (and require) sometimes does nothing, which would be undesireable here.

Anyway, the following might be the simplest answer:

use strict; use warnings; use myfirstaddin (); use mysecondaddin (); if (defined $ARGV[0] && $ARGV[0] eq 'second'} { mysecondaddin->import('runonce'); } else { myfirstaddin->import('runonce'); } print "hello world"; runonce(); myfirstaddin::runonce(); mysecondaddin::runonce();
# myfirstaddin.pm package myfirstaddin; BEGIN { require Exporter; our @ISA = qw( Exporter ); our @EXPORT_OK = qw( runonce ); } # Other "use" statements go here. sub runonce { print "This is file myfirstaddin."; } 1;
# mysecondaddin.pm package mysecondaddin; BEGIN { require Exporter; our @ISA = qw( Exporter ); our @EXPORT_OK = qw( runonce ); } # Other "use" statements go here. sub runonce { print "This is file mysecondaddin."; } 1;