QA

 <  Day Day Up  >  

Q&A

Q1:

In the File::Find module, what are the colons ( :: ) in the variable names ? Like $File::Find::dir ?

A1:

Perl modules can create alternate areas for variable names, called namespaces , so that the module's global variable names and your global variable names don't get mixed up. So a global variable in the Cwd module would be known as $Cwd::x . Most of your global variables actually have the full name of $main::x for $x . But for now, that's not important.

Q2:

I have a Windows 95/98/NT machine, and the module I want to use is not available through ActiveState's PPM . How can I install it?

A2:

Unfortunately, most of CPAN's modules assume that you have a full Unix-like development environment to compile and install modules; this kind of environment is not easy to put together on a Windows machine. If you're very handy with a C compiler, you can download a development environment and build your own module, but doing so is not easy. Some modules are written entirely in Perl, and it may just be a matter of opening the distribution and putting the files in the correct places.

Q3:

I have an older Perl program with require instead of use . What's require?

A3:

The require statement is similar to use , and because Perl 4 did not have the use keyword, it used require . (Follow that?) The require statement causes the interpreter to find a library file and include it in your program ”similar to use . However, the key difference is that a require happens whenever the require statement is run (at runtime), whereas the use directive happens when your program is first loaded (at compile time).

 <  Day Day Up  >  


SAMS Teach Yourself Perl in 24 Hours
Sams Teach Yourself Perl in 24 Hours (3rd Edition)
ISBN: 0672327937
EAN: 2147483647
Year: 2005
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net