$ cat -n variables.pl 1 #!/usr/bin/perl 2 #Crear una cadena de caracteres 3 $variable="Soy una variable que contiene una cadena"; 4 print("El contenido de \$variable es: \t $variable\n"); 5 #Crear una un numero real 6 $variable=3.141616; 7 print("El contenido de \$variable es: \t $variable\n"); 8 #Crear una un numero entero 9 $variable=55; 10 print("El contenido de \$variable es: \t $variable\n");Podemos obtener un listado haciendo:
$ perl -MO=Xref variables.pl File variables.pl Subroutine (definitions) Package UNIVERSAL &VERSION s0 &can s0 &isa s0 Package attributes &bootstrap s0 Subroutine (main) Package main $variable 3, 4, 6, 7, 9, 10 variables.pl syntax OKSi queremos redirigir la salida a fichero, podemos usar la opción
-o
$ perl -MO=Xref,-omatrixP.idx matrixP.pl $ cat -n matrixP.idx 1 File matrixP.pl 2 Subroutine (definitions) 3 Package Internals 4 &HvREHASH s0 5 &SvREADONLY s0 6 &SvREFCNT s0 7 &hash_seed s0 8 &hv_clear_placeholders s0 9 &rehash_seed s0 10 Package PerlIO 11 &get_layers s0 12 Package Regexp 13 &DESTROY s0 14 Package UNIVERSAL 15 &VERSION s0 16 &can s0 17 &isa s0 18 Package main 19 &matrixProd s30 20 &printMat s47 21 Subroutine (main) 22 Package main 23 $matA 53, 55, 58 24 $matB 54, 55, 60 25 $matC 55, 62 26 &matrixProd &55 27 &printMat &58, &60, &62 28 Subroutine matrixProd 29 Package (lexical) 30 $i i5, 20 31 $j i6, 17, 20, 22, 22, 25, 25 32 $k i6, 19, 22, 22 33 $matA i4, 7 34 $matB i4, 9 35 $nColsA i8, 13, 23 36 $nColsB i10, 25 37 $nRowsA i7, 27 38 $nRowsB i9, 13 39 $refMatC i11, 20 40 @$i 20, 22 41 @$k 22, 23, 23 42 @$matA 7, 8 43 @$matB 9, 10 44 @$refMatC 20, 22 45 @@$i 22, 22 46 @@$matA 8, 22 47 @@$matB 10, 22 48 @@$refMatC 22, 29 49 @@@$i 22, 27, 27 50 @@@$matA 22 51 @@@$matB 22 52 Package ? 53 @?? 8, 10 54 Package main 55 @_ 4 56 Subroutine printMat 57 Package (lexical) 58 $i i36, 41 59 $mat i33, 34 60 $nCols i35, 42 61 $nRows i34, 45 62 @$i 41, 45, 45 63 @$mat 34, 35 64 @@$mat 35, 41 65 @@@$mat 41 66 Package ? 67 @?? 35 68 Package main 69 $j 39, 41, 42, 42 70 @_ 33
Casiano Rodríguez León