I'm stuck on a problem of array printing and a "if" condition . I tried different combinations with the 'for' loop but the result always returns empty. Also when I try to include the "else" statement, I invariably get an "illegal instruction" message.
Could you help me on this?
--- SAMPLE ---
<h1>
L'école de la chair
</h1>
<div>
</div>
<!-- /rubric -->
<div class="colcontent">
<div class="rubric">
<p>
Date de parution:
<span class="bold">
<a href='/books/agenda.html?week=1963-10-06'>6 octobre 1963</a>
</span>
<br />
</p><!-- End first block -->
<p>
Auteur <span class="bold"><a href='/authors/indiv_gen=90843.html' title='Yukio Mishima'>Yukio Mishima</a></span>
<br /></p>
... etc
Traduction:
<a href='/books/all/lang-5001/'>français</a>,
<a href='/books/all/lang-5002/'>anglais</a>,
<a href='/books/all/lang-5004/'>espagnol</a>,
<a href='/books/all/lang-5129/'>allemand</a>.
<br/>
--- END SAMPLE ---
--- Expected output ---
L'école de la chair
6 octobre 1963
français, anglais,espagnol,allemand.
Thank you.
Could you help me on this?
--- SAMPLE ---
<h1>
L'école de la chair
</h1>
<div>
</div>
<!-- /rubric -->
<div class="colcontent">
<div class="rubric">
<p>
Date de parution:
<span class="bold">
<a href='/books/agenda.html?week=1963-10-06'>6 octobre 1963</a>
</span>
<br />
</p><!-- End first block -->
<p>
Auteur <span class="bold"><a href='/authors/indiv_gen=90843.html' title='Yukio Mishima'>Yukio Mishima</a></span>
<br /></p>
... etc
Traduction:
<a href='/books/all/lang-5001/'>français</a>,
<a href='/books/all/lang-5002/'>anglais</a>,
<a href='/books/all/lang-5004/'>espagnol</a>,
<a href='/books/all/lang-5129/'>allemand</a>.
<br/>
--- END SAMPLE ---
--- Expected output ---
L'école de la chair
6 octobre 1963
français, anglais,espagnol,allemand.
Code:
/usr/bin/awk '
function striptags() {
return gsub(/<[^>]*>/,"")
}
BEGIN {
n="#n/a"
}
/<[Hh]1>/{
getline
arr["title"]= $0
}
/week=[0-9]+/{
striptags()
arr["release"]=$0
}
# ... etc
/lang-[0-9]+/{
striptags()
arr["lang"]++
lang[$0]
#print $0 #<!-- for test only -->
}
# ... etc
END{
print arr["title"]
if (i=arr["release"]) print i; else print n
# ... etc
#print arr["lang"] #<!-- for test only -->
[COLOR=red][b]if (arr["lang"] > 0)
???
else
print n[/b][/color]
if (i=arr["editor"]) print i; else print n
# ... etc
}
Thank you.