• Publicidad

Modificar un html, en línea

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

Modificar un html, en línea

Notapor enric73 » 2013-07-13 06:26 @309

Hola compañeros,

Un proceso genera un html. Necesito añadirle en el <head> del html la siguiente línea para que me reconozca el encoding:
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Necesito automatizar este proceso. Con el siguiente comando tendría que añadirme en la 4ª fila del html la línea deseada, pero me peta por las comillas.
Sintáxis: [ Descargar ] [ Ocultar ]
Using bash Syntax Highlighting
  1. perl -pi -e 'print "<meta http-equip="content-type" content="text/html; charset=utf-8">\n" if $. == 4' olas.htm
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4


El mensaje error:
Sintáxis: [ Descargar ] [ Ocultar ]
Using bash Syntax Highlighting
  1. Bareword found where operator expected at -e line 1, near ""<meta http-equip="content"
  2.         (Missing operator before content?)
  3. String found where operator expected at -e line 1, near "type">\n""
  4. syntax error at -e line 1, near ""<meta http-equip="content"
  5. Execution of -e aborted due to compilation errors.
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


¿Me pueden ayudar?


Gracias
enric73
Perlero nuevo
Perlero nuevo
 
Mensajes: 154
Registrado: 2012-03-16 06:27 @311

Publicidad

Re: Modificar un html, en línea

Notapor explorer » 2013-07-13 06:32 @313

Sería algo así:
Sintáxis: [ Descargar ] [ Ocultar ]
Using bash Syntax Highlighting
perl -pi -e 'print qq(<meta http-equip="content-type" content="text/html; charset=utf-8">\n) if $. == 4' olas.htm
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

El operador qq() hace la misma función que las comillas dobles.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14480
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Modificar un html, en línea

Notapor enric73 » 2013-07-13 07:09 @339

Muchas gracias, explorer,

Sintáxis: [ Descargar ] [ Ocultar ]
Using bash Syntax Highlighting
  1. perl -pi -e 'print qq(<meta http-equiv="content-type" content="text/html; charset=utf-8">\n) if $. == 4' olas.htm
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


¡Ahora las ñ y tildes salen bien!

Saludos
enric73
Perlero nuevo
Perlero nuevo
 
Mensajes: 154
Registrado: 2012-03-16 06:27 @311


Volver a Básico

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 61 invitados

cron