background preloader

Perl

Facebook Twitter

Welcome to Roth Consulting. Perl Maven - pour ceux et celles qui veulent tirer le meilleur parti de la programmation en Perl. TAP. Package TAP; use strict; use vars qw( $VERSION ); $VERSION = '1.00'; TAP - The Test Anything Protocal TAP, the Test Anything Protocol, is Perl's simple text-based interface between testing modules such as Test::More and a test harness such as Test::Harness 2.x or TAP::Harness 3.x.

TAP's general format is: 1..N ok 1 Description # Directive # Diagnostic .... ok 47 Description ok 48 Description more tests.... For example, a test file's output might look like: 1..4 ok 1 - Input file opened not ok 2 - First line of the input valid ok 3 - Read the rest of the file not ok 4 - Summarized correctly # TODO Not written yet In this document, the "harness" is any program analyzing TAP output. A harness must only read TAP output from standard output and not from standard error. The version The current version of TAP is 12.

TAP version 13 In the absence of any version line version 12 is assumed. The plan The plan tells how many tests will be run, or how many tests have run. Means you plan on running 10 tests. Www.catonmat.net/download/perl1line.txt. Perl - passing hash and array to function problem. File::Spec. The Comprehensive Perl Archive Network - www.cpan.org.

Perl for System Administration. Hashes of Arrays (Programming Perl) Use a hash of arrays when you want to look up each array by a particular string rather than merely by an index number. In our example of television characters, instead of looking up the list of names by the zeroth show, the first show, and so on, we'll set it up so we can look up the cast list given the name of the show. Because our outer data structure is a hash, we can't order the contents, but we can use the sort function to specify a particular output order. 9.2.1. Composition of a Hash of Arrays You can create a hash of anonymous arrays as follows: # We customarily omit quotes when the keys are identifiers. To add another array to the hash, you can simply say: $HoA{teletubbies} = [ "tinky winky", "dipsy", "laa-laa", "po" ]; 9.2.2.

Here are some techniques for populating a hash of arrays. Flintstones: fred barney wilma dino jetsons: george jane elroy simpsons: homer marge bart you could use either of the following two loops: You can append new members to an existing array like so: 9.2.3. Perl HowTo | Your source for Perl tips, howto's, faq and tutorials. Hashes. Hashes are complex list data, like arrays except they link a key to a value. To define a hash, we use the percent (%) symbol before the name. defineahash.pl: #! /usr/bin/perl print "content-type: text/html \n\n"; # DEFINE A HASH %coins = ("Quarter", 25, "Dime", 10, "Nickel", 5); # PRINT THE HASH print %coins; Display: Nickel5Dime10Quarter25 Hashes can be indexed using two scalar variables.

Legiblehash.pl: #! Nickel, 5 Dime, 10 Quarter, 25 The each() function takes a hash. Hashes work really well with HTML Tables. tablehashes.pl: #! We have yet to sort our hash so you may experience different arrangements of your keys than shown in the display box. Sorting any hash requires the use of the sort() function that has previously been outlined in PERL Arrays. Sortkeys.pl: Dime: 10 Nickel: 5 Quarter: 25 The $coins($key) represents the variable assigned by PERL to each value of each element.

Hashes may be sorted by value. We need to edit our hash to and change is the values to floating-point numbers. . #! #! #! Formation Perl - Guide Perl : tables de hachage. Dernière version sur © 2002-2015 Sylvain Lhullier - Permission est accordée de copier et distribuer ce document sans modification et à condition de fournir un lien vers la page 6. Tables de hachage Les tables de hachage de Perl ne se retrouvent pas dans beaucoup d'autres langages ; pour les avoir souvent utilisées en Perl, il est dur de repasser à des langages qui n'en sont pas pourvus.

Une table de hachage (hash table en anglais) est un type de donnée en Perl permettant d'associer une valeur à une clef. On peut dire d'un tableau (notion abordée précédemment) qu'il associe une valeur scalaire à un entier : à la position i (pour i entier), une certaine valeur scalaire est présente. Je peux, par exemple, avoir envie de gérer en Perl un index téléphonique simple : chacun de mes amis a un numéro de téléphone, je veux pouvoir retrouver leur numéro à partir de leur prénom. 6.1.

My %h; my %h = (); 6.2. 6.3. 6.4. Perl Regex Interactive Tutorial. Win32::AdminMisc FAQ. The Win32::AdminMisc extension is used for a small variety of miscellaneous administrative tasks that we felt were not addressed (but needed) in the standard Win32::NetAdmin extension that comes with Win32 Perl from ActiveState. Current Version The current version of Win32::AdminMisc is 20030714 and can be found at either: The Roth Consulting FTP site. Here you are guaranteed to get the latest and most up-to-date version. A Roth Consulting Accounts C++ library.

Back to the top How to discover your Win32 Perl build number You can discover which build of Win32 Perl you have by entering: perl -v of which you should see something similar to: The bold text is the build number. List of Functions: ComputerAliasAdd( $Machine, $Alias ) This will add a computer alias to the computer specified by $Machine.

The second parameter ($Alias) is a name (not a proper computer name) so don't prepend any slashes. A computer alias is another name which a machine will respond to. Example: Returns: $CommandString %Config.