Professional Perl Programming
Shelley Powers, Simon Cozens, Peter Wainwright, Aldo Calpini, Arthur Corliss, Juan Julian Merelo Guervos, Chris Nandor, Aalhad S
Format: PDF / Kindle (mobi) / ePub
Perl is one of the most important scripting languages in use today. Open source, freely available, portable, versatile, and robust, powerful and easy to use, Perl is the first choice for thousands of professional web developers. But Perl is far more than a scripting language for the web. Supported by a comprehensive standard library and hundreds of third-party libraries, Perl is an increasingly popular choice for application programming.
This book provides comprehensive coverage of the Perl language. It covers the fundamentals of data types and file handling through advanced features like regular expressions, object-oriented programming, threads, internationalization, and integrating Perl with the C programming language. The latest version of the language, Perl 5.6, is used throughout, with commentary for those with earlier versions.
cd perl-5.6.0 If we have the GNU version of tar we can also do the unpacking in one step with: > tar -xzvf stable.tar.gz Perl builds easiest on UNIX platforms; the majority of these can use the supplied Configure script to set up and compile Perl with the features and installation locations they want. Other platforms supported by the source bundle are documented in one of the README files available in the top-level directory of the source tree. For instance, instructions and additional details
number will be if printed before actually doing so: $pi = atan2(1, 0) * 2; # a numeric value $length_as_string = length($pi); # length as string TE The index and rindex functions look for a specified substring within the body of a string. They do not have any of the power or flexibility of a regular expression, but by the same token, they are considerably quicker. They return the position of the first character of the matched substring if found, or -1 (technically one less than the index start
the .= operator: #!/usr/bin/perl # concat.pl use warnings; use strict; my my my my $First = "One "; $First_Addition = "Two "; $Second_Addition = "Three"; $string = $First; print "The string is now: $string \n"; $string.= $First_Addition; print "The string is now: $string \n"; $string.= $Second_Addition; print "The string is now: $string \n"; > perl concat.pl The string is now: One The string is now: One Two The string is now: One Two Three Beware of using combination assignments in other
used whenever we stack indices or hash keys together when we use multidimensional arrays (arrays of arrays) or hashes of hashes. That is: $element = $pixel3d [$x] [$y] [$z]; Is actually shorthand for: $element = $pixel3d [$x] -> [$y] -> [$z]; Which is, in turn, shorthand for: $yz_array = $pixel3d [$x]; $z_array = $yz_array -> [$y]; $element = $z_array -> [$z]; This is because an array or hash can only contain scalars, so an array of arrays is really an array of array references. Perl is smart
5) To really remove the element or hash key, we use the delete function: my @array = (1, 2, 3, 4, 5); # define a five element array delete @array[1..3]; # no more second, third, and fourth elements 168 Beyond Scalars - More Data Types Constants A constant is a value that remains unchanged throughout the lifetime of a program. By defining named constants and then using them rather than the values we can avoid retyping, and potentially mistyping, the value, and additionally it makes our code