Dear Friends, I've got problems with a perl script in which I've got an if-else instruction. The perl program called readit.pl is used for a bilingual form: Catalan-Spanish. The first variable to be stored in ANUNCIS.TXT is the date. In Catalan, all week days start by DI and something else. So, to recognise Catalan, I use the week days. Here is my perl script for you to check if the if-else structure is correct:
my $n=1; open (LOG, "log/anuncis.txt") || die "$!"; while (<LOG>) { chomp; my @attributes = split /\|/; if ($attributes[0] =~m/Di*/){ print "<TABLE WIDTH=65% BORDER=2 ALIGN=CENTER>\n"; print "<TR BGCOLOR=#00FF00B><B>Anunci número $n del $attri +butes[0]</B></TR>\n"; print "<TR>De <B>$attributes[1] $attributes[2]</B> que vol + vendre <FONT COLOR=#FA8072><B>$attributes[6] a $attributes[7] ?.</B> +</FONT></TR>\n"; print "<TR>Us hi podeu posar en contacte al(s) telèfon(s) +<B><FONT COLOR=#FA8072>$attributes[8] // $attributes[9]</B></FONT></T +R>\n"; print "<TR>Segons l'horari que ens indica: <B><FONT COLOR= +#FA8072>$attributes[5]</B></FONT></TR>\n"; print "<TR>O bé al correu electrònic: <B>$attributes[10]</ +B> o a la seva URL <B>$attributes[11]</B></TR>\n"; print "<TR BGCOLOR=#FFA500><B>AQUESTS SÓN ELS SEUS COMENTA +RIS:</B>\n"; print "<BR><FONT COLOR=#8B0000><I><B>$attributes[12]</I></ +B></TR></FONT></TABLE>\n"; print "<BR><BR>\n";} else{ print "<TABLE WIDTH=65% BORDER=2 ALIGN=CENTER>\n"; print "<TR BGCOLOR=#9999FF><B>Anuncio número $n del $attri +butes[0]</B></TR>\n"; print "<TR>De <B>$attributes[1] $attributes[2]</B> que des +ea vender <FONT COLOR=#003366><B>$attributes[6] a $attributes[7] ?.</ +B></FONT></TR>\n"; print "<TR>Os podéis poner en contacto con el/ella en los +teléfonos <B><FONT COLOR=#003366>$attributes[8] // $attributes[9]</B> +</FONT></TR>\n"; print "<TR>Según el horario que nos idica: <B><FONT COLOR= +#003366>$attributes[5]</B></FONT></TR>\n"; print "<TR>Su e-Mail es: <B>$attributes[10]</B> y su URL: +<B>$attributes[11]</B></TR>\n"; print "<TR BGCOLOR=#FF9999><B>ESTOS SON SUS COMENTARIOS:</ +B>\n"; print "<BR><FONT COLOR=#333333><I><B>$attributes[12]</I></ +B></TR></FONT></TABLE>\n"; print "<BR><BR>\n";} $n++; } close LOG;
Thank you very much for your kind help!

Edit kudra, 2002-06-15 READMORE tag added


In reply to If-else problem by Kuntent

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.