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

Re: :) modules modules modules

Expand Messages
  • Sean
    First off, I m assuming you ve created a database handle with a statement sort of like this: $dbh = DBI- connect($data_source, $username, $auth, %attr); Next,
    Message 1 of 9 , Oct 1, 2001
    • 0 Attachment
      First off, I'm assuming you've created a database handle with a
      statement sort of like this:

      $dbh = DBI->connect($data_source, $username, $auth, \%attr);

      Next, I'd ask what happens if when you put the execute statement in
      the main package.

      --- In perl-beginner@y..., Merlijn uyttersprot <merlijn_u2@y...> wrote:
      > Hello All,
      > Raining greetings from Belgium;
      >
      > I'll scetch my situation:
      >
      > MAIN PRORGAM:
      >
      > #!/opt/local/perl/bin/perl
      > use strict;
      > use DBI;
      > use CGI;
      > use pln_show_data;
      > ....
      > my $stmt="Select * from dual";
      > $db->{RaiseError} = 0;
      > $dt = $db->prepare($stmt) || die
      > "$stmt\n$DBI::errstr\n";
      > ....
      >
      >
      >
      > MODULE pln_show_data:
      >
      > #!/opt/local/perl/bin/perl -w
      > use strict;
      > use DBI;
      > package pln_show_data;
      > ...
      > $main::dt->execute;
      > ...
      >
      >
      > this generates error:
      > Can't call method "execute" on an undefined value at
      > pln_show_data.pm (on the line of the execute)
      >
      >
      > My taughts: You can't prepare a statement in another
      > memory "place". -> I'm forced to put the prepare
      > statement in the same module? is this correct.
      > Pitty is that it isn't possible in the current code to
      > put the prepare there)
      >
      >
      > Any ideas?
      >
      > Merlijn
      >
      >
      > Ps: (why am I using modules -> Current code has 3800
      > lines in one PERL file, I'm trying to cut it in
      > subroutines/modules so later on I can work with more
      > friends at the same time on different files/modules then.)
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Listen to your Yahoo! Mail messages from any phone.
      > http://phone.yahoo.com
    • Sean
      First off, I m assuming you ve created a database handle with a statement sort of like this: $dbh = DBI- connect($data_source, $username, $auth, %attr); Next,
      Message 2 of 9 , Oct 1, 2001
      • 0 Attachment
        First off, I'm assuming you've created a database handle with a
        statement sort of like this:

        $dbh = DBI->connect($data_source, $username, $auth, \%attr);

        Next, I'd ask what happens if when you put the execute statement in
        the main package.

        --- In perl-beginner@y..., Merlijn uyttersprot <merlijn_u2@y...> wrote:
        > Hello All,
        > Raining greetings from Belgium;
        >
        > I'll scetch my situation:
        >
        > MAIN PRORGAM:
        >
        > #!/opt/local/perl/bin/perl
        > use strict;
        > use DBI;
        > use CGI;
        > use pln_show_data;
        > ....
        > my $stmt="Select * from dual";
        > $db->{RaiseError} = 0;
        > $dt = $db->prepare($stmt) || die
        > "$stmt\n$DBI::errstr\n";
        > ....
        >
        >
        >
        > MODULE pln_show_data:
        >
        > #!/opt/local/perl/bin/perl -w
        > use strict;
        > use DBI;
        > package pln_show_data;
        > ...
        > $main::dt->execute;
        > ...
        >
        >
        > this generates error:
        > Can't call method "execute" on an undefined value at
        > pln_show_data.pm (on the line of the execute)
        >
        >
        > My taughts: You can't prepare a statement in another
        > memory "place". -> I'm forced to put the prepare
        > statement in the same module? is this correct.
        > Pitty is that it isn't possible in the current code to
        > put the prepare there)
        >
        >
        > Any ideas?
        >
        > Merlijn
        >
        >
        > Ps: (why am I using modules -> Current code has 3800
        > lines in one PERL file, I'm trying to cut it in
        > subroutines/modules so later on I can work with more
        > friends at the same time on different files/modules then.)
        >
        > __________________________________________________
        > Do You Yahoo!?
        > Listen to your Yahoo! Mail messages from any phone.
        > http://phone.yahoo.com
      • Merlijn uyttersprot
        All set, been doing the copy of the other prepare query sub.;. pointed my error to some friends... been drinking lots of coffee.. Still no solution.. I thought
        Message 3 of 9 , Oct 1, 2001
        • 0 Attachment
          All set,

          been doing the copy of the other prepare query sub.;.
          pointed my error to some friends...
          been drinking lots of coffee..

          Still no solution..

          I thought it could be the compiler, strying prefs in
          the comp´┐Żler for different linking...

          Ate some French frites

          searched a bit further,
          then ERROR 7300
          whahahah

          Found it, I had forgotten to put SUB

          sub pln_show_data{.....

          works fine now

          /me becomes red, and has shame

          Merlijn

          Sorry bothering you all :)



          --- Sean <perlmongrel@...> wrote:
          > First off, I'm assuming you've created a database
          > handle with a
          > statement sort of like this:
          >
          > $dbh = DBI->connect($data_source, $username, $auth,
          > \%attr);
          >
          > Next, I'd ask what happens if when you put the
          > execute statement in
          > the main package.
          >
          > --- In perl-beginner@y..., Merlijn uyttersprot
          > <merlijn_u2@y...> wrote:
          > > Hello All,
          > > Raining greetings from Belgium;
          > >
          > > I'll scetch my situation:
          > >
          > > MAIN PRORGAM:
          > >
          > > #!/opt/local/perl/bin/perl
          > > use strict;
          > > use DBI;
          > > use CGI;
          > > use pln_show_data;
          > > ....
          > > my $stmt="Select * from dual";
          > > $db->{RaiseError} = 0;
          > > $dt = $db->prepare($stmt) || die
          > > "$stmt\n$DBI::errstr\n";
          > > ....
          > >
          > >
          > >
          > > MODULE pln_show_data:
          > >
          > > #!/opt/local/perl/bin/perl -w
          > > use strict;
          > > use DBI;
          > > package pln_show_data;
          > > ...
          > > $main::dt->execute;
          > > ...
          > >
          > >
          > > this generates error:
          > > Can't call method "execute" on an undefined value
          > at
          > > pln_show_data.pm (on the line of the execute)
          > >
          > >
          > > My taughts: You can't prepare a statement in
          > another
          > > memory "place". -> I'm forced to put the prepare
          > > statement in the same module? is this correct.
          > > Pitty is that it isn't possible in the current
          > code to
          > > put the prepare there)
          > >
          > >
          > > Any ideas?
          > >
          > > Merlijn
          > >
          > >
          > > Ps: (why am I using modules -> Current code has
          > 3800
          > > lines in one PERL file, I'm trying to cut it in
          > > subroutines/modules so later on I can work with
          > more
          > > friends at the same time on different
          > files/modules then.)
          > >
          > > __________________________________________________
          > > Do You Yahoo!?
          > > Listen to your Yahoo! Mail messages from any
          > phone.
          > > http://phone.yahoo.com
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Listen to your Yahoo! Mail messages from any phone.
          http://phone.yahoo.com
        • Ferry I
          ... Here is a possibility (though I may not be 100% right) Your script use pln_show_data; The use statement require compiling pln_show-data.pm when called,
          Message 4 of 9 , Oct 2, 2001
          • 0 Attachment
            At 06:49 01/10/01 -0700, Merlijn uyttersprot wrote:
            >Can't call method "execute" on an undefined value at
            >pln_show_data.pm (on the line of the execute)

            Here is a possibility (though I may not be 100% right)

            Your script use pln_show_data;
            The use statement require compiling pln_show-data.pm when called, which, at
            the time it was called, $main::dt is thus not initialized at all.

            The following might help :
            * May be you can move the use pln_show_data; a few lines lower after the
            line where you initialize $main::dt

            #!/opt/local/perl/bin/perl
            use strict;
            use DBI;
            use CGI;
            ....
            my $stmt="Select * from dual";
            $db->{RaiseError} = 0;
            $dt = $db->prepare($stmt) || die
            "$stmt\n$DBI::errstr\n";
            use pln_show_data;

            * May be you can also try using "require" instead of "use"

            Once again, I may not 100% correct, but I hope it will do any help :)

            Best Regards,
            Ferry I
          Your message has been successfully submitted and would be delivered to recipients shortly.