Perl en Español

  1. Home
  2. Tutoriales
  3. Foro
  4. Artículos
  5. Donativos
  6. Publicidad
 


Página 1 de 1  [ 5 mensajes ] 
 
Nota 2011-12-07 10:56 @497

Perlero Senior
Registrado: 2009-03-01 18:39 @818
Mensajes: 387
Cómo usar perltidy en Windows
Hola, me acabo de bajar el siguiente archivo http://sourceforge.net/projects/perltid ... p/download, porque quiero usar perltidy. El problema es que no sé cómo usarlo porque el único archivo .pl que hay es makefile.pl. Lo cargo y se sale.

¿ Alguien me podría explicar cómo usarlo o instalarlo ?


Nota 2011-12-07 11:10 @507

Perlero Senior
Registrado: 2009-03-01 18:39 @818
Mensajes: 387
Editores Perl
Estoy buscando editores Perl al estilo perltidy; me refiero a que tenga indentación automática.

¿ Alguien me ayuda ?


Nota 2011-12-07 12:13 @550
Avatar de Usuario
Administrador
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España
Mensajes: 10250
Re: Editores Perl
perltidy (CPAN) no es un editor de textos, es un formateador de textos.

En la página de manual que te enlazo viene la explicación de su funcionamiento.

Yo lo uso mucho, sobre todo para formatear el código Perl que la gente publica en estos foros.

Esta es la configuración que estoy usando ahora (fichero ~/.perltidyrc):
Syntax: [ Download ] [ Hide ]
Using text Syntax Highlighting
#------
#------  A .perltidyrc configuration file for the nice tool Perltidy
#------              You found it at http://www.leifove.com.
#------  Note! Because of the -b option used below, the original Perl file
#------        is backed up by Perltidy, and the original then tidyied.  
#------  See CPAN. org for more info about where to store this file and
#------  how to call Perltidy on your source code files.
#------

#----------------  PBP options, as listed on page 35 of PBP  ----------------
-pbp    # equivale a:
-l=120   # Max line width is 78 cols
#-i=4    # Indent level is 4 cols
#-ci=4   # Continuation indent is 4 cols
#-vt=2   # Maximal vertical tightness
#-cti=0  # No extra indentation for closing brackets
#-pt=1   # Medium parenthesis tightness
#-bt=1   # Medium brace tightness (for non-code blocks)
#-sbt=1  # Medium square bracket tightness
#-bbt=1  # Medium block brace tightness (for code blocks)
#-nsfs   # No space before semicolons
#-nolq   # Don't outdent long quoted strings
        # Break before all operators:
#-wbb="% + - * / x != == >= <= =~ !~ < > | & = // **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
-bbao   # --break-before-all-operators.

# Note that the PBP book has a typo on page 35 when defining the above -wbb
# option, see http://oreilly.com/catalog/perlbp/errata/perlbp.confirmed
# The above string is correct.

#----------  Perltidy default options (i.e. in line with PBP)  --------------
-asc    # Add any missing optional semicolon at the end of a line
-aws    # Add certain whitespace to improve code readability
-tqw    # Default handling of multi-line 'qw' quotes
-ibc    # Indent block comments to same level as the code
-msc=4  # Minimum 4 spaces between code and same-line comments
-fpsc=40 # Don't try to line up all comments to a fixed column
-hsc    # Align hanging side comments
-sbc='^#{2,}[^\s#]'    # Enable static block comments
-nssc   # No special handling for static side comments
-dnl    # Delete old newlines
-bbc    # Ensure a blank line before every full-line comment
-bbs    # Ensure a blank line before every sub definition (except one-liners)
-bbb    # Ensure a blank line before code blocks (for, while, if, ....)
-lbl=8  # Minimum number of lines between each -bbb inserted blank line

#-------------  Additional options, based on PBP recommendations  ------------
-bar    # K&R style code braces
-nolc   # Long comments indented, even when this make the total line length "too long"
-noll   # Long lines indented, even when this make the total line length "too long"
-nola   # Don't treat labels as special cases when indenting

#----------  Options concerning Perltidy's input and ouput files  -----------
-nst    # Do NOT output to STDOUT (since we want to use -b)
-b      # Backup the input file to .bak and perform all tidying in the original file
-se     # Write errors to STDERR
-ple    # Preserve the EOL character(s). E.g. in case Perltidy runs
        # on Windows, but processes a Perl file for Unix (and vice versa)

#-----------  Some other Perltidy options, intentionally not used   ----------
# The following Perltidy options are NOT consistent with PBP and should NOT be used:
# -lp, -icb, -fws, -nwls, -nwrs, -sfp, -sak/-nsak, -csc/dcsc, -fnl,
# -ce, -bl, -sbl, -bli, -blil, -bbvt, -otr, -sct, -boc, -kis,
# -pbp (because the -wbb list typo in the PBP book carried over to Perltidy (!))
# The following Perltidy options are not used, for other reasons:
# -sot, -mft, -cab, -bol, -bok/-nbok, -bot/-nbot, -iob, -isbc
Verás que hace mucha referencia a las siglas PBP, que son las correspondientes al libro Perl Best Practices, de Damian Conway, donde da una serie de reglas para programar Perl siguiendo un estilo claro.

PerlTidy se encarga de leer un código por su entrada estándar, y siguiendo las indicaciones de las opciones en la línea de comandos, o en el fichero .perltidyrc, formatearlo y entregarlo en la salida estándar.

PBP tiene un capítulo donde habla de esta herramienta y da unos consejos, que se resumen en una serie de opciones para PerlTidy.

En cambio, si lo que quieres es un editor de código Perl, de este tema ya hemos hablado en otros hilos:

_________________
JF^D Perl programming


Nota 2011-12-07 12:19 @554

Perlero Senior
Registrado: 2009-03-01 18:39 @818
Mensajes: 387
Re: Editores Perl
Gracias. Hice así y me sirvió.

Código:
perl perltidy test.pl -o final.pl


Además, en la opción -i de perltidy ¿qué número conviene más para el formateo? Otra cosa: ¿me podrías explicar cómo puedo indentar bien en Perl tanto usando este programo o haciéndolo a mano? Espero no quitarte tiempo pero tengo muchas dudas sobre indentación en Perl.


Nota 2011-12-07 17:00 @750
Avatar de Usuario
Administrador
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España
Mensajes: 10250
Re: Editores Perl
El valor de -i está puesto por defecto a 4. Si repasas el archivo de configuración que he puesto antes, verás que también estaba así.

Yo suelo usar editores que indentan (sangran) de forma más o menos automática). Desde la terminal, con joe o vim, o en entorno gráfico, con Padre o Eclipse, te ayudan en esa parte de la edición.

Otros editores no específicos de Perl, como Kate (en Linux) o Notepad++ (en Windows), también hacen muy buena labor.

_________________
JF^D Perl programming


Responder al tema  [ 5 mensajes ] 

Reglas del Foro
No puedes abrir nuevos temas en este Foro
No puedes responder a temas en este Foro
No puedes editar tus mensajes en este Foro
No puedes borrar tus mensajes en este Foro
No puedes enviar adjuntos en este Foro

Publicidad

Socializa

Síguenos por Twitter

Suscríbete GRATUITAMENTE al Boletín de Perl en Español

Saltar a:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Traducción al español por Huan Manwë para phpbb-es.com
phpBB SEO