[Tallahassee-pm] Questions and such

Rebekah Landbeck rlandbeck at uniteddatatronics.com
Tue Jul 1 11:56:26 CDT 2003


At 10:52 AM 7/1/2003, Ryan Carmelo Briones wrote:

 > Questions concerning Exporter:
 >
 > 1)  Is using Exporter necessary/the best way to include a seperate package
 > file?
only if you're importing functions or variables into the main namespace.
otherwise, no need for exporter. you could always use Object-Oriented
programming and create a class would probably make it a lot easier...

Thanks.  Sounds like using Exporter will make the most sense for this; 
there's only one function in the package, and it returns the, um... PHP 
would call it the resource link_identifier for the db connection, which is 
needed in the main namespace as written.

And I just deleted another series of questions because James just addressed 
them.  :o)

The questions I deleted... they're dead, Jim.  Sorry.  Couldn't resist.  I 
get a little loony when I feel I'm on the verge of *getting $it*.  Ok, 
maybe a lot.


 >
 > 2)  The PHP include() reads the file into the current one as if the code
 > were written in the current file.  I haven't come across anything that I
 > can recall in PHP regarding namespaces, but I have an ok grasp of the
 > concept.  I think.  The Exporter doc says "use ModuleName; This imports
all
 > the symbols from ModuleName's @EXPORT into the namespace of the use
 > statement." Does that essentially mean the same thing?
no, if you want to do the same as PHP's include(), you'll want Perl's
require() or do(). in this case you wouldn't use "use Module;" if you use
Exporter and @EXPORT you'd have to specify every function you wanted import
into main.

*Adding 'require' and 'do' to @look_me_up*

In @EXPORT or @EXPORT_OK, the doc says the ampersand in front of a function 
is optional, and that implementation is faster without the ampersand.  Why 
is it faster?  I read that the 'use' statement loads the module into memory 
if it isn't already, so why would exporting the function by reference slow 
it down?  Does it look somewhere other than where the module's loaded in 
memory if the function's marked as a reference?  Ok, so my curiosity's 
sidetracking me... you only live once.  :o)


 >
 > 3)  I read that exporting method names isn't good.  Is that why you would
 > use Modulename();, importing no symbols?
"use Modulename;" is normally used for OO packages. Perl programmers are
really anal. it's not REALLY bad to export THINGIES into the main namespace,
it's just "bad form" according to the Perl wizards.

Now I'm thinking of Dustin Hoffmann in Hook...

<snip of book recommendations>

Those sound great.  And I've got a long weekend sans family coming up...  :o)

on a side note, i think you should really look into the best ways you can
use the CPAN. there are loads and loads of modules there to make your job a
lot easier. i don't know what you're using now, but when you run into one
task that looks like it's going to take more than a page of code, you should
really look towards the CPAN.

I'll go browsing sometime.  Thanks.

Rebekah 




More information about the Tallahassee-pm mailing list