Hace unos dias me pregunto alguien como sustituir el $ por un caracter n veces, despues de buscar encontre que es asi:
#!/usr/bin/perl
$cadena="uno";
$cadena =~ s/$/" " x 2 /e;
print $cadena;
Referencia: Perlop
jueves, 5 de agosto de 2010
miércoles, 17 de marzo de 2010
Comandos protocolo POP...
telnet machine 110
POP commands:
USER uid Log in as "uid"
PASS password Substitue "password" for your actual password
STAT List number of messages, total mailbox size
LIST List messages and sizes
RETR n Show message n
DELE n Mark message n for deletion
RSET Undo any changes
QUIT Logout (expunges messages if no RSET)
TOP msg n Show first n lines of message number msg
POP commands:
USER uid Log in as "uid"
PASS password Substitue "password" for your actual password
STAT List number of messages, total mailbox size
LIST List messages and sizes
RETR n Show message n
DELE n Mark message n for deletion
RSET Undo any changes
QUIT Logout (expunges messages if no RSET)
TOP msg n Show first n lines of message number msg
viernes, 12 de febrero de 2010
Just Another Perl / Unix Hacker
#!/usr/bin/perl
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord ($p{$_})&6];$p{$_}=/ $P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Referencia:
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord ($p{$_})&6];$p{$_}=/ $P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Referencia:
viernes, 18 de diciembre de 2009
Contador antes del fin del mundo.... perl Tk
#!/usr/local/bin/perl -w
#####################################
# Contador para el fin del mundo
#
#######################
use Date::Calc qw(Delta_DHMS);
use Time::localtime;
use strict;
use Tk;
my @W_End = (2012, 12, 21, 00, 00, 01); # 21 Dec 2012, 0:00:01
my $str = "...";
my $mw = new MainWindow;
$mw->title("Fin del mundo");
$mw->Label(-text => "Faltan para el fin del mundo")->pack;
my $entry = $mw->Entry(
-textvariable => \$str,
-width => 17,
-font => "{Comic Sans MS} 12",
-relief => 'raised',
-highlightthickness => 0,
-state => 'disable',
)->pack();
$mw->Button(-text => 'Quit',
-justify => 'center',
-command => sub{exit} )->pack;
$mw->repeat(1000 => \&downcounter);
MainLoop;
sub downcounter {
# Calculando fecha actual
my @Today = (localtime->year()+ 1900, localtime->mon()+ 1, localtime->mday(), localtime->hour(), localtime->min(), localtime->sec());
my @diff = Delta_DHMS(@Today, @W_End);
if ( $diff[1] <10 ){
$diff[1]="0$diff[1]";
}
if ( $diff[2] <10 ){
$diff[2]="0$diff[2]";
}
if ( $diff[3] <10 ){
$diff[3]="0$diff[3]";
}
$str = "$diff[0] dias, $diff[1]:$diff[2]:$diff[3] ";
}
#####################################
# Contador para el fin del mundo
#
#######################
use Date::Calc qw(Delta_DHMS);
use Time::localtime;
use strict;
use Tk;
my @W_End = (2012, 12, 21, 00, 00, 01); # 21 Dec 2012, 0:00:01
my $str = "...";
my $mw = new MainWindow;
$mw->title("Fin del mundo");
$mw->Label(-text => "Faltan para el fin del mundo")->pack;
my $entry = $mw->Entry(
-textvariable => \$str,
-width => 17,
-font => "{Comic Sans MS} 12",
-relief => 'raised',
-highlightthickness => 0,
-state => 'disable',
)->pack();
$mw->Button(-text => 'Quit',
-justify => 'center',
-command => sub{exit} )->pack;
$mw->repeat(1000 => \&downcounter);
MainLoop;
sub downcounter {
# Calculando fecha actual
my @Today = (localtime->year()+ 1900, localtime->mon()+ 1, localtime->mday(), localtime->hour(), localtime->min(), localtime->sec());
my @diff = Delta_DHMS(@Today, @W_End);
if ( $diff[1] <10 ){
$diff[1]="0$diff[1]";
}
if ( $diff[2] <10 ){
$diff[2]="0$diff[2]";
}
if ( $diff[3] <10 ){
$diff[3]="0$diff[3]";
}
$str = "$diff[0] dias, $diff[1]:$diff[2]:$diff[3] ";
}
martes, 8 de diciembre de 2009
Link sobre perl....
Estaba vagando por la red y vi este link que considero esta interesante:
http://perlenespanol.com/articulos/archivo/000112.html
http://perlenespanol.com/articulos/archivo/000112.html
lunes, 7 de diciembre de 2009
Contador antes del fin del mundo....
Dado que segun se acabara el mundo el 21 de diciembre del 2012, hay que saber cuanto tiempo nos sobra; para eso este contador en perl.
Nota: No es el mejor, pero funciona. Ademas esta el detalle de que en realidad no se cual es la hora exacta de dicho fin, por lo que el programa supone que sera en el segundo 1 del ese dia.
:D
============================================
#!/usr/bin/perl
#####################################
# Contador para el fin del mundo
#
#######################
use Date::Calc qw(Delta_DHMS);
use POSIX qw(strftime);
@W_End = (2012, 12, 21, 00, 00, 01); # 21 Dec 2012, 0:00:01
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime;
@Today = ( 1900+$year, 1+$mon, $mday, $hour, $min, $sec);
@diff = Delta_DHMS(@Today, @W_End);
print " $diff[0] days, $diff[1]:$diff[2]:$diff[3] \n";
Aqui esta otra version y creo es mejor:
#!/usr/bin/perl
#####################################
# Contador para el fin del mundo
#
# cortesia de Salvador Ortiz.
#######################
#
use Date::Calc qw(Delta_DHMS Today_and_Now);
printf "Faltan %d dias, %2d:%2d:%2d para el fin del mundo\n",Delta_DHMS(Today_and_Now, 2012, 12, 21, 00, 00, 01);
Nota: No es el mejor, pero funciona. Ademas esta el detalle de que en realidad no se cual es la hora exacta de dicho fin, por lo que el programa supone que sera en el segundo 1 del ese dia.
:D
============================================
#!/usr/bin/perl
#####################################
# Contador para el fin del mundo
#
#######################
use Date::Calc qw(Delta_DHMS);
use POSIX qw(strftime);
@W_End = (2012, 12, 21, 00, 00, 01); # 21 Dec 2012, 0:00:01
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime;
@Today = ( 1900+$year, 1+$mon, $mday, $hour, $min, $sec);
@diff = Delta_DHMS(@Today, @W_End);
print " $diff[0] days, $diff[1]:$diff[2]:$diff[3] \n";
Aqui esta otra version y creo es mejor:
#!/usr/bin/perl
#####################################
# Contador para el fin del mundo
#
# cortesia de Salvador Ortiz.
#######################
#
use Date::Calc qw(Delta_DHMS Today_and_Now);
printf "Faltan %d dias, %2d:%2d:%2d para el fin del mundo\n",Delta_DHMS(Today_and_Now, 2012, 12, 21, 00, 00, 01);
martes, 10 de noviembre de 2009
Bomba fork....
Referencia:
bomba fork
Comando shell:
:(){ :|:& };:
Solucion en Linux:
Agregar en el archivo /etc/security/limits.conf la linea;
* hard nproc 1024
Asi se limita a 1024 el numero de procesos que pueden correr simultaneamente.
bomba fork
Comando shell:
:(){ :|:& };:
Solucion en Linux:
Agregar en el archivo /etc/security/limits.conf la linea;
* hard nproc 1024
Asi se limita a 1024 el numero de procesos que pueden correr simultaneamente.
Suscribirse a:
Entradas (Atom)