Loading ...
Sorry, an error occurred while loading the content.

redefinition warnings

Expand Messages
  • Weyer, Jens
    Hello ! First of all I would like to introduce myself, because i am new to this mailinglist. My name is Jens, i am living in Germany and i am 24 years old.
    Message 1 of 4 , Mar 15 2:06 AM
    • 0 Attachment
      Hello !
       
      First of all I would like to introduce myself, because i am new to this mailinglist.
      My name is Jens, i am living in Germany and i am 24 years old.
      I've been working with Linux, Perl, HTML and all the stuff around since 1996,
      so I would suppose, that I am not new to the internet-djungle :-)
       
       
      In our company we use a Linuxserver as a webserver, so there should be no
      problem running dynamically generated pages. BUT there came an order to
      rebuilt our web-content based onto ASP due to conformity. I hate this word :|
      Nevertheless - we did not want to swap our Linuxserver with a m$ IIS...
      We could arrange it, that we can keep our Server on running as it is, but
      we still had to use ASP... So I found the Apache::ASP project.
       
      We modified the given ASP sourcecodes, that they could be executed
      at our server.
       
      Now there is a huge problem: We have an ASP file for every page on
      that server, and in each file exists the same subs like
      Write_Content_HTML() and so on. We include there the main content
      of each webpage dynamically. There are more such subs, but one should
      be enough to explain the problem.
      The code works fine, but the error_logs are full of redefinition warnings,
      due to the fact, that the same subs are used in each ASP file.
       
      So I looked for a solution, and found the mailing-list archive, where I
      searched for a solution. I found some matching posts, but none of them
      described the desired solution.
       
      I also used the configuration entry "UniquePackages 0", so there would
      not be one global "memory". That solved the problem with the redefinition
      errors, but now the sources did not run anymore, because the subs did
      not "know" each other.
       
      I don't know how to solve that, instead of set UniquePackages to 0 and
      review our sources, but that would be too complex...
       
      I really hope you know a better way... Thanks in advance !
       
      Bye,
      Jens
       
    • Joshua Chamas
      ... Yeah, you are an old timer all right. Welcome to the club. :) ... I implemented the buzzword because I figured there would be greater acceptance of the
      Message 2 of 4 , Mar 15 2:40 AM
      • 0 Attachment
        > "Weyer, Jens" wrote:
        >
        > Hello !
        >
        > First of all I would like to introduce myself, because i am new to this mailinglist.
        > My name is Jens, i am living in Germany and i am 24 years old.
        > I've been working with Linux, Perl, HTML and all the stuff around since 1996,
        > so I would suppose, that I am not new to the internet-djungle :-)
        >

        Yeah, you are an old timer all right. Welcome to the club. :)

        > Nevertheless - we did not want to swap our Linuxserver with a m$ IIS...
        > We could arrange it, that we can keep our Server on running as it is, but
        > we still had to use ASP... So I found the Apache::ASP project.
        >

        I implemented the buzzword because I figured there would be greater
        acceptance of the platform as a technology. Thanks for the validation
        of the approach. & between Apache::ASP & Linux, I could not ask for
        a nicer web dev enviroment.

        > Now there is a huge problem: We have an ASP file for every page on
        > that server, and in each file exists the same subs like
        > Write_Content_HTML() and so on. We include there the main content
        > of each webpage dynamically. There are more such subs, but one should

        I think it is bad form to define subroutines in ASP scripts.
        However, like you found, setting UniquePackages to 1 can make
        it so that redefinition warning go away. But then you no longer
        have the global namespace to work with, so right your code stops
        working that was relying on this.

        You should find some way to share your subroutines ideally.
        One easy was to do this is to put them all in the global.asa
        file, and pass parameters to them to change their behavior
        on a per script basis. Another thing to try is to decomp
        your application logic into a global object with methods.
        You can set the global object in global.asa like:

        == httpd.conf
        PerlSetVar UseStrict 1

        == global.asa
        use vars qw($Object);
        sub Script_OnStart {
        $Object = Object->new();
        }

        Then you can call in each script:

        <% $Object->Write_Content_HTML(); %>

        Depending on the $Object state, your method call might change
        its behavior, so you can tailor the method execution on
        a per script basis that way too. Sometimes objects are
        better for state control, than passing parameters.

        A more concrete script example might suggest better what
        approach might work here if the above didn't help enough.

        --Josh
        _________________________________________________________________
        Joshua Chamas Chamas Enterprises Inc.
        NodeWorks Founder Huntington Beach, CA USA
        http://www.nodeworks.com 1-714-625-4051

        ---------------------------------------------------------------------
        To unsubscribe, e-mail: asp-unsubscribe@...
        For additional commands, e-mail: asp-help@...
      • Joshua Chamas
        ... Hey Jens, I am glad to hear that moving the subs to global.asa is working out. If there are just too many subs like this after a while & your global.asa
        Message 3 of 4 , Mar 15 5:35 PM
        • 0 Attachment
          Joshua Chamas wrote:
          >
          > You should find some way to share your subroutines ideally.
          > One easy was to do this is to put them all in the global.asa
          > file, and pass parameters to them to change their behavior
          > on a per script basis. Another thing to try is to decomp
          > your application logic into a global object with methods.
          > You can set the global object in global.asa like:
          >

          Hey Jens,

          I am glad to hear that moving the subs to global.asa is working out.
          If there are just too many subs like this after a while & your
          global.asa gets too messy, consider using the GlobalPackage config
          so that you can have a separate perl module for these subs like this:

          == httpd.conf
          PerlSetVar GlobalPackage My::Site

          == perllib/My/Site.pm
          sub first {}
          sub second {}

          Since all ASP scripts will now be compiled into the My::Site package,
          everything defined in that package, just like the global.asa
          can be globally shared across all your ASP scripts. Note you still
          need to keep ASP event handlers like Script_OnStart in global.asa
          even if you have a separate package like this, but using this
          approach helps keep ASP centric event handlers separate from
          your other misc subroutines.

          --Josh
          _________________________________________________________________
          Joshua Chamas Chamas Enterprises Inc.
          NodeWorks Founder Huntington Beach, CA USA
          http://www.nodeworks.com 1-714-625-4051

          ---------------------------------------------------------------------
          To unsubscribe, e-mail: asp-unsubscribe@...
          For additional commands, e-mail: asp-help@...
        • Ellers
          ... I m not sure if it helps in your situation, but I sometimes find it useful to treat ASP s Include facility as a kind of subroutine substitute. That is,
          Message 4 of 4 , Mar 17 9:31 PM
          • 0 Attachment
            >
            >Now there is a huge problem: We have an ASP file for every page on
            >that server, and in each file exists the same subs like
            >Write_Content_HTML() and so on. We include there the main content
            >of each webpage dynamically. There are more such subs, but one should
            >be enough to explain the problem.
            >The code works fine, but the error_logs are full of redefinition warnings,
            >due to the fact, that the same subs are used in each ASP file.

            I'm not sure if it helps in your situation, but I sometimes find it
            useful to treat ASP's Include facility as a kind of subroutine
            substitute.

            That is, instead of:

            $result = do_something( 'arg1', $arg2 );

            sub do_something
            {
            my ( $first, $second ) = @_;
            ...
            return 1;
            }


            I do:

            $result = $Response->Include( 'my_sub_do_something.asp', 'arg1', $arg2 );

            [my_sub_do_something.asp]

            <%
            my ( $first, $second ) = @;

            ...

            return 1;
            %>



            I appreciate not everyones needs are the same as mine - and the above
            doesn't eliminate using packages and the global.asa, but sometimes
            I've found it useful.


            HTH
            Ellers


            ---------------------------------------------------------------------
            To unsubscribe, e-mail: asp-unsubscribe@...
            For additional commands, e-mail: asp-help@...
          Your message has been successfully submitted and would be delivered to recipients shortly.