Friday, October 28, 2011

Perl - Pattern Matching [ Print`s ... ]

#!/usr/bin/perl use strict; use warnings; my $text = "encrypted key\n"; if ($text =~  /key/){     print qq/$text new print !\n/; } if(lc ($text) =~ /key/){     print "$text"; } $text = "/home /andre /work /tmp /bin"; if($text =~ m[/bin]){     print "Directory /tmp found!\n"; } $text = "andre luiz\n"; $text =~ s(andre)<AnDrE>; $text =~ s[l]/L/; $text =~...

Wednesday, October 26, 2011

Perl - Pattern Matching [ regular expression ]

Metacharacter: Actually, they are very useful and have special meanings within the patterns./ | () [] {} ^ $ * +? .\: The backslash and a wildcard that has the 'power' to transform into something special character literale.g. \ b \ D \ t \ 3 Pattern #!/usr/bin/perl use...

Monday, October 24, 2011

Perl - (school media) [hash , array]

#file txt separado por tab alunosnotasbimestral ayes    8.5 6.5 7.0 10.0 andre   7.0 9.0 8.5 8.5 la  9.0 7.0 4.5 7.5 gui 4.5 8.0 8.0 6.0 lu  4.0 4.0 4.0 4.0 ----------------------------------------------------------------------------------------------------------------------------- #!usr/bin/perl use strict; use warnings; my %nomes; my $media = 0; my $qnt = 4; open(IN,'alunosnotasbimestral')...

Saturday, October 22, 2011

Mysql - [ Sub Query ] function (exists,)

mysql> select * from tabela3; +--------+--------+-------+------------+ | nome   | codigo | idade | data       | +--------+--------+-------+------------+ | gilmar |      1 |    24 | 2011-10-10 | +--------+--------+-------+------------+ 1 row in set (0.00 sec) mysql> select * from tabela2; +-----------+-------+--------+------------+ | nome1  ...

Friday, October 21, 2011

Perl [ hash - Single sample ]

Assuming you have a sample with a column that presenter replications.you to remove repetitions and maintain a single sample! ----------------------------------------------------------------------------------------------------------- #!/usr/bin/perl use strict; use warnings; various boot =cut   # commeted  my %hash; $hash{1}='hard'; $hash{1}='soft'; $hash{1}='hard'; $hash{1}='soft'; $hash{2}='perl'; $hash{2}='linux'; $hash{2}='perl';$hash{2}='linux'; =cut my...

Thursday, October 20, 2011

Perl - [ Hash / Sub / Sort / Keys ]

#!/usr/bin/perl use strict; use warnings; my (%HoHoA); @{$HoHoA{'1'}{'1'}} = (1..10); @{$HoHoA{'1'}{'2'}} = (11..20); @{$HoHoA{'1'}{'3'}} = (21..30); @{$HoHoA{'1'}{'4'}} = (31..40); &print_ed(\%HoHoA); sub print_ed{     my ($rHoHoA) = @_;     foreach my $kA (keys %{$rHoHoA}){         foreach my $kB ( sort{$rHoHoA->{$kA}{$b}[1] <=> $rHoHoA->{$kA}{$a}[3]...

Tuesday, October 18, 2011

Perl - [ Functions / Reference ]

#!/usr/bin/perl use strict; use warnings; &a(); sub a{         my @nome = ('ayres','andre');         print "Rotina a antes: " , join ("\t",@nome) , "\n";         &print_a(\@nome);         print "Rotina a depois: " , join ("\t",@nome) , "\n"; } sub print_a{         my ($rA_teste) = @_;  ...

Perl - [ References /pointers variables ]

Anyone familiar with the C language (and other), you know whatpointers are and how programming can become proficient with its use. References are pointers to previously defined data types(whether it's scalars, arrays or hashes). Through references it is possible to obtain the contents of a scalar variable, an...

Friday, October 14, 2011

Perl - ( if ) [ testing if uninitialized variable! ]

#!/usr/bin/perl use strict; use warnings; my $key ; not initialized if($key != 0){ # line 7     print "1ok\n"; } if($key != ''){  # line 10     print "2ok\n"; } if($key ne 0){ # line 13     print "3ok\n"; } if($key ne ''){ #line  16     print "4ok\n"; } if($key){ # line 19     print "5ok\n"; } resul $ perl tmp.pl Use of uninitialized...

Thursday, October 13, 2011

Perl Hash [SINTAXE]

 high voltage =) ---------------------------------------------------------------------------------------------------------------------------------- #!/usr/bin/perl use strict; use warnings;\ my $key = 1; my $hash; @{$hash->{$key}} = ("10","11"); $hash->{1}[2] = "sintaxe\n"; print join ("|",@{$hash->{1}}); Result $ perl tmp.pl  10|11|sintaxe...

Friday, October 7, 2011

Perl - [ Expression ]

#!/usr/bin/perl use strict; use warnings; my $var = 'LGMB-RP_06242011_HGWSI_1.fastq.sai.sam.bam.sort.bam'; if( $var =~ /^(.*)\.fastq/ ){     $var = $1; } print"$var\n"; $var = 'LGMB-RP_06242011_HGWSI_1.fastq.sai.sam.bam.sort.bam'; $var = "$1.sam" if( $var =~ /^(.*)\.sam/ ); print"$var\n"; $ perl t.pl LGMB-RP_06242011_HGWSI_1 LGMB-RP_06242011_HGWSI_1.fastq.sai.sam...

Thursday, October 6, 2011

Perl - A [ Switch ] statement

Necessary import library. Initialize the variable and play ($val). #!/usr/bin/perl use strict; use warnings; use Switch; my $val = 'a'; switch ($val) { case 1 { print "number 1" } case "a" { print "string a" } case [1..10,42] { print "number in list" } case /\w+/ { print "pattern" } case qr/\w+/ { print "pattern" } else { print "previous...

Wednesday, October 5, 2011

Perl - [Function] (Sort)

Number #!usr/bin/perl use strict; use warnings; my @blog = (1,7,6,34,2,46,7); print "disorderly\n"; print join (" ",@blog); @blog = sort @blog; print "\norderly - the first number\n"; print join (" ",@blog); print "\norderly - the complete number( descending order )\n"; @blog = sort {$b <=> $a} @blog; print join (" ",@blog); print...