On Aug 11, 7:18 pm, [EMAIL PROTECTED] (Chris Pax) wrote: > i have two files > > ###########callbacks.pm############### > sub foo{ > return "foo"; > } > > sub bar{ > return "foo"; > } > > 1; > ################# > > ############main.pl############## > #!/usr/bin/perl > > #PSUDO CODE# > #open callbacks.pm > #remove 1; > #write "sub moo{\n\treturn \"moo\";\n}\n" > #write "1;" > > package mainprog; > use callbacks; > > print foo(); > print bar(); > print moo(); > 1; > ###################3 > > you see here what i want to happen. what I am doing is writing a new > function to the callbacks file, then I want to import the file.
You have a problem here unrelated to your desire to re-write the module. You are declaring subroutines in the package main, but trying to call them in package mainprog. Perl won't be able to find those subroutines regardless. Your problem that actually has to do with the question is that you're using 'use'. 'use' happens at compile time. That means it happens long before the code that re-writes callbacks.pm is executed. You need 'require' instead. perldoc -f use perldoc -f require Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/