• Publicidad

Variables y html

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

Variables y html

Notapor joss » 2007-09-16 11:31 @521

Tengo un problema al incluir html en la variable:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
$mensaje=" <html><head><style type="text/css">
<!--
body,td,th {
        color: #FFFFFF;
}
body {
        background-color: #000000;
}
-->
</style><title>prueba!</title></head><body>

<div align="
center">
  <p><strong>prueba!</strong></p>
  <p><strong><img src="
http://img502.imageshack.us/img502/244/espanaxr0.jpg"></strong></p>
  <p><strong>prueba</strong></p>
<center>---------------------------------</center>
  <p><strong>prueba!!!</strong></p>

</div>
</body></html> "
;

open (PAGINA, ">sphate.html");

print PAGINA $mensaje;
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4


Seguro que me faltan algunas comillas o algo, para señalar al interprete que es código HTML y no Perl.
joss
Perlero nuevo
Perlero nuevo
 
Mensajes: 36
Registrado: 2007-09-10 13:04 @586

Publicidad

Notapor creating021 » 2007-09-16 12:27 @560

No, es que te hace falta "quitar" un par :lol: .
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
$mensaje=" <html><head><style type=\"text/css\">
<!--
body,td,th {
   color: #FFFFFF;
}
body {
   background-color: #000000;
}
-->
</style><title>prueba!</title></head><body>

<div align=\"center\">
  <p><strong>prueba!</strong></p>
  <p><strong><img src=\"http://img502.imageshack.us/img502/244/espanaxr0.jpg\"></strong></p>
  <p><strong>prueba</strong></p>
<center>---------------------------------</center>
  <p><strong>prueba!!!</strong></p>

</div>
</body></html> "
;

open (PAGINA, ">sphate.html");

print PAGINA $mensaje;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Pero yo usaría algo como:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
my $mendaje = <<'EOF';
#Aquí va la página
EOF


#Recuerda dejar una línea después del EOF
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Expect the worst, is it the least you can do?
Avatar de Usuario
creating021
Perlero frecuente
Perlero frecuente
 
Mensajes: 595
Registrado: 2006-02-23 16:17 @720
Ubicación: Frente al monitor

Notapor explorer » 2007-09-16 21:19 @930

Es más cómodo usar comillas simples...

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
$mensaje = '<html><head><style type="text/css">
<!--
body,td,th {
        color: #FFFFFF;
}
body {
        background-color: #000000;
}
-->
</style><title>prueba!</title></head><body>

<div align="center">
  <p><strong>prueba!</strong></p>
  <p><strong><img src="http://img502.imageshack.us/img502/244/espanaxr0.jpg"></strong></p>
  <p><strong>prueba</strong></p>
<center>---------------------------------</center>
  <p><strong>prueba!!!</strong></p>

</div>
</body></html>'
;

open (PAGINA, ">sphate.html");

print PAGINA $mensaje;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
(Es más cómodo usar comillas simples porque dentro de ESTE texto HTML no las hay)
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

Notapor kidd » 2007-09-17 09:16 @428

El maravilloso Perl que nos brinda más de una posibilidad para hacer las cosas.

En caso de que quieras interpolar variables no podrías usar las comillas sencillas, y pues escapar todas las comillas dobles es demasiado trabajo y alguna se te puede escapar por ahí, entonces podrías usar el operador qq:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
$mensaje = qq( <html><head><style type="text/css">
<!--
body,td,th {
        color: #FFFFFF;
}
body {
        background-color: #000000;
}
-->
</style><title>prueba!</title></head><body>

<div align="center">
  <p><strong>prueba!</strong></p>
  <p><strong><img src="http://img502.imageshack.us/img502/244/espanaxr0.jpg"></strong></p>
  <p><strong>prueba</strong></p>
<center>---------------------------------</center>
  <p><strong>prueba!!!</strong></p>

</div>
</body></html> );

open (PAGINA, ">sphate.html");

print PAGINA $mensaje;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Uriel Lizama Perl programmer fundador de Perl en Español
Perl Programming Language
Avatar de Usuario
kidd
Creador de Perl en Español
Creador de Perl en Español
 
Mensajes: 1166
Registrado: 2003-10-15 16:52 @744
Ubicación: México

Notapor joss » 2007-09-19 12:22 @557

Gracias por vuestras respuestas.
joss
Perlero nuevo
Perlero nuevo
 
Mensajes: 36
Registrado: 2007-09-10 13:04 @586


Volver a Básico

¿Quién está conectado?

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