Wednesday, 16 June 2010
Reference material- Perl syntax summary by O'Reilly / -other-: $var, @arr $arr[ $index], %hash $hash{$key}
- Database Management in PERL - DBI
- Database Management in PERL - DBI - timeout handling
my $am = Graph::AdjacencyMatrix->new($g, distance_matrix => 1); -- implemented as: use 5.006; use strict; use warnings; package Graph::AdjacencyMatrix; use Parent::Class; our $VERSION = '4.4'; our @ISA = qw(Parent::Class); our @EXPORT = qw(export_functions_by_default); # otherway export everything .. sub new { my ($class, $g, %opt) = @_; my $self = $class->SUPER::new( $_[1], $_[2], $_[3] ); --OR-- my $self = { _firstName => shift, _lastName => shift, _ssn => shift, }; ... bless $self, $class; } sub MyMethod { my $self = shift; $self->SUPER::MyMethod(); print " MySubClass::MyMethod called!\n"; } isa (package name) can (function name)
Formatting Strings w/ Formatting Characters \Q..\E - here
Regular expression especials - here
Here operator here
File operators: z -e -f -d ... here
Perl reference:
- ref EXPR -- if (ref($r) eq "HASH") -- Returns SCALAR ARRAY HASH CODE REF GLOB LVALUE FORMAT IO VSTRING Regexp
- our $var_name -
- our $VERSION = qv("v1.2.3"); # shorthand
- $Module::VERSION.
- use Module VERSION LIST
- my $x = "abc" x 3; #$x is now the string "abcabcabc"
- my @a = ("abc") x 3; #@a is now ("abc", "abc", "abc")
- Prototypes: sub mylink ($$) -- mylink $old, $new
- Operator (..) :
my $x = ("a" .. "z")[$i]; #$x is now "e"
my $y = ("a" .. "z")[-$i]; #$y is now "w"
my @a = ("a" .. "z")[0 .. $i]; #@a is now ("a", "b", "c", "d", "e")
my @b = ("a" .. "z")[1, 0, 3]; #@b is now ("b", "a", "d")
Number of elements in an array:
$#ARGV - scalar index del último elementos
scalar( @ARGV ) - número de elementos
No comments:
Post a Comment