redifined functions

Help
columbus
2005-04-01
2013-05-20
  • columbus
    columbus
    2005-04-01

    Hello I have a small problem with my perl-code.
    I made serveral modules in which I put my functions. Theses functions call other functions in other modules. So at the beginning of each module I have an include-list like this ( My_modul_3.pm ):
    [code]
    use My_modul_1.pm;
    use My_modul_2.pm;
    use My_modul_4.pm;
    use Strict;
    etc...
    [/code]

    But this causes warnings in Eclipse/Epic about:
    ! subroutine my_function_1 redefined at line ...

    This is not serious but it disturbes a little bit, and I ask myself: is this only a problem for Epic or a real Perl-problem????

    And I want to put a feature to the wish list.
    Epic needs very urgent the ability to execute code on a remote machine. In my case I use eclipse on a x86 linux box but the target is HPUX. I have to copy the code manualy each time via ftp. And I think Im not the only one. So how can I do this?

    Thank you...

    Gruss Christian

     
    • LeO
      LeO
      2005-04-06

      About remote: Why not mount the target-dir as Samba? I'll do it via Windows-Eclipse and Solaris-Perl. NO problem at all.

       
    • columbus
      columbus
      2005-04-08

      We dont have Samba on this Server nor SFTP nor SSH. Nothing. :-(

       
      • LeO
        LeO
        2005-04-12

        I'm not quite sure, but there is a plugin on the Eclipse which should handles FTP-access as well. But never tried it and don't know how good/bad it works.

         
    • Peter Guzis
      Peter Guzis
      2005-04-13

      The issue with redefined functions is related to Perl itself and will manifest itself outside of EPIC provided warnings are enabled.  It's not really a problem per se(*), but rather Perl warning you when you define the same function more than once, or in your case recursively include modules (e.g. Module1 uses Module2 which in turn uses Module1.)

      You can tickle the same warning message with something like:

      use warnings;

      sub imadupe {}
      sub imadupe {}

      If you leave out the "use warnings;" you will notice no warning is displayed.

      Depending on your requirements, you can try a few things to make the warning go away.

      1. Re-evaluate why you are recursively including modules.  Often there is an alternative way of achieving your goal.  A primer on Design Patterns can really help with this option.
      2. Include the modules only once from a "parent" module.  Unless you are exporting symbols, this works fairly well.  The downside to this is the modules in question are no longer self-sufficient and won't work correctly without the aforementioned "parent" loaded first.
      3. Add "no warnings;" to the top of each of the affected modules.  You will of course lose any useful warnings that might help you spot hard-to-find errors.  You can mitigate this by using warnings during development and turning them off for released code.

      * Generally speaking, redefined functions are harmless.  However, they can cause problems in persistent environments such as mod_perl, PerlIS, or PerlEx.  If there is even the slightest chance your code will be running under such interpreters, I recommend you avoid the above option #3.