Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Example:

----
#!/app/perl5.005/bin/perl package First; sub new { bless {}, 'First' }; sub test { my $self=shift; bless $self, 'Second'; } 1; package Second; sub test { my $self=shift; print "Hello World!\n"; } 1; package main; my $t=new First(); print $t,"\n"; # Output: First=HASH(0x2864) $t->test; # no output; print $t,"\n"; # Output: Second=HASH(0xc2864) $t->test; # Output: Hello World!
----

I have a data(base) load script I am working. It's quite flexible as to the source and the destination of the data. (Could be to<=>from a file, database, etc) Currently I have conditionals to work around problems. EG: Transfering from Sybase 2 Sybase I have a problem with text fields. You can't bind text. Oracle 2 Oracle, longs are implicitly bound (binded?) as a varchar which means any data over 4000 chars and oracle complains, etc. I can work around these issues w/ conditionals but I thought a more elegent approach would be to move this to a module. If the load doesn't work one way, try another approach. (Replace the current namespace w/ a new one and try that.)

This is especially attractive, because the next approach may not even resemble the one that failed. Maybe it fails over to native tools when both backends are the same. Oracle: Exp/Imp.. Sybase: BCP.. Neither of these would require a loop on cursor approach. In fact, it wouldn't require a loop at all! But a select<=>insert cursor loop is "easier" for Sybase to Oracle. (I tried bcp->sql*load. A terrible hack!)

Anyway.. My question is: Is this approach as ellegant as I think? Is it a bad hack and prone to problems? The "original" caller may need to know how the data was actually transfered so replacing the namespace is the only decent way I see to do this. It sounds good to me, being fairly new to PerlOO, and I've always been told, if it looks to good to be true, it probably is.

Your thoughts would be greatly appreciated!

SMF 8)

In reply to Replacing namespaces by smferris

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-05-18 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (176 votes). Check out past polls.

    Notices?