background preloader

Structure

Facebook Twitter

Dsc - Perl Data Structures Cookbook. <div class="noscript"><p><strong>Please note: Many features of this site require JavaScript.

dsc - Perl Data Structures Cookbook

You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser. </strong></p><p> To get the best experience, please enable JavaScript or download a modern web browser such as <a href=" Explorer 8</a>, <a href=" <a href=" or <a href=" Chrome</a>. </p></div> perldsc - Perl Data Structures Cookbook Perl lets us have complex data structures. For $x (1 .. 10) { for $y (1 .. 10) { for $z (1 .. 10) { $AoA[$x][$y][$z] = $x ** $y + $z; } } } Alas, however simple this may appear, underneath it's a much more elaborate construct than meets the eye! How do you print it out? As you see, it's quite easy to become confused. This document is meant to be a detailed but understandable treatment of the many different sorts of data structures you might want to develop.

Let's look at each of these possible constructs in detail. You can (and should) read more about references in perlref. . #! Perlfunc - Perl builtin functions. The functions in this section can serve as terms in an expression.

perlfunc - Perl builtin functions

They fall into two major categories: list operators and named unary operators. These differ in their precedence relationship with a following comma. (See the precedence table in perlop.) List operators take more than one argument, while unary operators can never take more than one argument. Thus, a comma terminates the argument of a unary operator, but merely separates the arguments of a list operator.

In the syntax descriptions that follow, list operators that expect a list (and provide list context for the elements of the list) are shown with LIST as an argument. Any function in the list below may be used either with or without parentheses around its arguments. If you run Perl with the -w switch it can warn you about this. A few functions take no arguments at all, and therefore work as neither unary nor list operators. Perl was born in Unix and can therefore access all common Unix system calls.

Example: print "Can do. NAME data structure complex data structure struct - search.cpan. Perldsc - Perl Data Structures Cookbook Perl lets us have complex data structures.

NAME data structure complex data structure struct - search.cpan.

You can write something like this and all of a sudden, you'd have an array with three dimensions! For $x (1 .. 10) { for $y (1 .. 10) { for $z (1 .. 10) { $AoA[$x][$y][$z] = $x ** $y + $z; } } } Alas, however simple this may appear, underneath it's a much more elaborate construct than meets the eye! How do you print it out? As you see, it's quite easy to become confused. This document is meant to be a detailed but understandable treatment of the many different sorts of data structures you might want to develop. Let's look at each of these possible constructs in detail. Arrays of arrays hashes of arrays arrays of hashes hashes of hashes more elaborate constructs But for now, let's look at general issues common to all these types of data structures. You can't use a reference to an array or hash in quite the same way that you would a real array or hash.

You can (and should) read more about references in perlref.