Perl - nest modules and access subroutines from 2nd level nested modules in main script -
Is possible in Perl in the Nest module and export all nested subroutines scripts that use parent module? Consider the following example:
The main script will use subtitle from Paint MDUD. Therefore, the script will contain the following line:
  Usage Parine Module;     ParentModule  will use subprotoin from  ChildModule . Therefore, the following line will be in  ParentModule :    Use child modules;    Will there be suburounines exported under the  Child Module  available under the main script?   Some time ago I asked a similar question and did not answer, but it is already different from the meaning. Apart from this I have tried the scenario described above and it did not work.  
 All modules uses the exporter.  
 Thanks   
 
   parent module  for export < Code> ChildModule  will need to be provided explicitly. Since you are using  exporter , the easiest way to do this is:   In  ChildModule.pm :    Package Child Module; Strict use; Use warnings; Use the base 'exporter'; Our @ Export = ('CF'); ParentModule.pm :  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Use warnings; Use Base 'Exporter'; Use Child Module; Our @ Export = ('PF', @ Child Module :: Exports); Sub PF {Print "Generator \ n"} 1; < / Code>  
 After that,  
 % perl -MParentModule -e 'pf; cf' parent child    This is usually Not good for exporting things by default, recent However, you can play the same tricks with  @EXPORT_OK , but you still have to  ChildModule  routine to  ParentModule  or  ParentModule  will not be able to export them.   There are other modules that allow you to avoid that last step (for example), but you have a custom  import ()  Routine In  ParentModule  if you want to use the simple  ParentModule  statement.   
 
  
Comments
Post a Comment