Basic HTML version of Foils prepared April 16,1996

Foil 11 require and use in Perl5

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 Material -- April 16,1996. by Geoffrey C. Fox


require Cwd; # Makes notation Cwd:: accessible
$here = Cwd::getcwd(); # correctly accesses function getcwd in module Cwd
$here = getcwd(); # looks for getcwd in current file and probably fails!
On the otherhand:
use Cwd; # Actually imports names (symbol table) from Cwd and
$here = getcwd(); # is equivalent to $here = Cwd::getcwd();
Can use require with Perl prgroms -- not packages
  • require "fred.pl"; # reads this file and thereby includes any functions included in file. acts like a library call in that will not read fred.pl if already done!



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997