| Códigos Útiles en Perl, creados por joshue moises | |
| Índice : | |
| 1.- Redireccionamiento. | |
| 2.- Enviar Mail con SendMail | |
| 3.- Parse Form | |
| 4.- Template | |
| 5.- Convertir Tags a < | |
| 6.- Open and Write A Flat File | |
| 7.- Inicio Programa (cabecera) | |
| 8.- Include a configuration File | |
| 9.- Generate Primary ID KEY | |
| 10.- Remove Bar Returns for Flat File Storage | |
| 11.- Mostrar las Enviroment Variables | |
| 12.- Date in 6 digit format | |
| 13.- Sub Write File | |
| 14.- Print Location | |
| 15.- Count Word String | |
| 16.- Count Letters string | |
| 17.- Content Type | |
| 18.- Replace car returns seed | |
| Redireccionamiento de Browser. | |
| print "Location: $destino\n\n"; | |
| Enviar Mail con SendMail | |
| $maillocation =
"/usr/lib/sendmail"; $email = "direccionemail\@hotmail.com" open (MAIL, "| $maillocation -t") || die "aw, cant use $maillocation"; print MAIL "To: $email\n"; print MAIL "Reply-to: $emailcliente\n"; print MAIL "From: $emailcliente\n"; print MAIL "Subject: Envio de Recetas\n"; print MAIL "=======================================================\n"; print MAIL "Envio de Receta\n"; |
|
| Parse Form | |
| &parse_form;
sub parse_form { |
|
| Template | |
| $templatepath = "c:\\portal\\cocina\\"; $template = "tmpl01.html"; open(HTMLFILE,"$templatepath" . "$template") or &ohdear("Imposible abrir : $template"); $vitrinaText = $vitrinaText . " HTML A METER "; ############### Template Print ####################
sub ohdear |
|
| Convertir Tags a < | |
| $linktitle =~ s/</\</g; $linkdescrip =~ s/</\</g; |
|
| Open and Write A Flat File | |
| $file = "s2fsdfsdfds.dat" $path = "c:\\raiz\\temp\\"; $filename = "$path" . "$file" &open_file("FILE1",">>",$filename); sub open_file { |
|
| Inicio de Programa Cabecera | |
| #!/usr/bin/perl | |
| Include a configuration File | |
| require 'C:\portal\sdfgsdf\config.cgi';
############### in config.cgi ##################### $fields = 5; # Number of fields in each record |
|
| Generate Primary ID KEY | |
| $linkurl = &generatePassword;
sub selectRandomChar sub generatePassword |
|
| Remove Bar Returns for Flat File Storage | |
| #Remove Bar Returns
$linkdescrip =~ tr/\n/+/; #Add Bar Returns $linkdescrip =~ s/\+/<br>/g; |
|
| Enviroment variables : | |
| #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<tt>\n"; foreach $key (sort keys(%ENV)) { print "$key = $ENV{$key}<p>"; } print "<hr>"; print "$ENV{'DOCUMENT_ROOT'}\n"; |
|
| ########Date in 6 digit format ######### | |
$datestamp = sprintf "%02d%02d%02d", ((localtime)[5]%100, (localtime)[4]+1, (localtime)[3]); print $datestamp; |
|
| sub write_file | |
| sub write_file { local ($filevar, $line) = @_; print $filevar ($line); } |
|
| print location | |
print "Location: $opt2?op=izq\n\n"; |
|
| count words string | |
$str = "And now to Xanthus' gliding stream they dove..."; $count = $str =~ s/((^|\s)\S)/$1/g; print $count; |
|
|
|
|
|
|
|
|
|
|
|
(C) Joshué Moisés García S. |
|