Loginskip to content

November 2nd, 2006

do so with a reference to a hash

do so with a reference to a hash (or an object); but in practice, most of the uses you’d have for those things aren’t necessary. There’s no need to write special code for linked lists (although there’s a book that shows you how if you have some exotic need[3]); Perl’s arrays grow on demand quite well enough. Most of the reasons to construct trees are taken care of by Perl’s efficient algorithm for looking up elements in hashes. (Again, if you have a need that somehow manages to overwhelm this mechanism, the same book provides alternatives.) [3] Mastering Algorithms with Perl, by Jon Orwant, Jarkko Hietaniemi and John Macdonald (O’Reilly, 1999). Some of the system calls you’re accustomed to look like they were taken behind the woodshed by the tool set and given a workover to extend their usefulness. Instead of taking just one file as argument, chmod, chown, and unlinkall take a list of filenames as arguments instead of just one. Oddly enough, mkdirand rmdirdo not take lists of directory names even though their command line counterparts do. ‘lint’ is spelled ‘usestrict’ and ‘-w’ in Perl. 12.3 Tips for the FORTRAN Programmer Perl code appears quite odd to a FORTRAN programer. FORTRAN uses ( ) (parentheses) exclusively for indices. An array element has the form ARRELM(1), a matrix element has the form MATELM(1,1), and a subroutine call takes the form CALL ASUB ( VALUE1, VALUE2 ), whereas Perl uses ( ) (parentheses), [ ] (brackets), and { } (braces) in various ways depending on data type and function. For instance, whereas $a[$i]refers to an element of an array, $a{$i} refers to a value in a hash. Forgetting the proper uses of these separators is a common error for the neophyte Perler experienced in FORTRAN. If you use FORTRAN for its native handling of high-precision floating point numbers (and if you don’t what are you using it for?), then you’ll find Perl’s IEEE floating point too imprecise (just as if you were to program in C). You may find solace in the PDLmodule from CPAN or the Math::BigFloatmodule in the Perl core. COMMON blocks are an evil way of passing around scads of global variables at the same time and are used far more often in FORTRAN than they should be. (If you want to define common constants used by many FORTRAN files, use a preprocessor; this isn’t the ’60s, you know.) The way to make available a set of constants that share some common theme in Perl is to put them into a module, using the Exporter, and then import them where you want them: % cat myconsts.pm package myconsts; use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(PI E); use constant PI => 3.14159265; use constant E => 2.71828183; 1; # Modules must return a true value % cat mytest

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services

Comments are closed.