Starting a web browser: Difference between revisions

(Added Perl example)
Line 375:
<tr bgcolor="#d7fffe"><td>Karl-Weysser-Str. 6</td><td>Karl-Weysser-Str.</td><td>6</td></tr>
</table>
 
=={{header|Phix}}==
<lang Phix>constant addresses = {"Plataanstraat 5",
"Straat 12",
"Straat 12 II",
"Dr. J. Straat 12",
"Dr. J. Straat 12 a",
"Dr. J. Straat 12-14",
"Laan 1940 - 1945 37",
"Plein 1940 2",
"1213-laan 11",
"16 april 1944 Pad 1",
"1e Kruisweg 36",
"Laan 1940-'45 66",
"Laan '40-'45",
"Langeloërduinen 3 46",
"Marienwaerdt 2e Dreef 2",
"Provincialeweg N205 1",
"Rivium 2e Straat 59.",
"Nieuwe gracht 20rd",
"Nieuwe gracht 20rd 2",
"Nieuwe gracht 20zw /2",
"Nieuwe gracht 20zw/3",
"Nieuwe gracht 20 zw/4",
"Bahnhofstr. 4",
"Wertstr. 10",
"Lindenhof 1",
"Nordesch 20",
"Weilstr. 6",
"Harthauer Weg 2",
"Mainaustr. 49",
"August-Horch-Str. 3",
"Marktplatz 31",
"Schmidener Weg 3",
"Karl-Weysser-Str. 6"}
 
function isDigit(integer ch)
return ch>='0' and ch<='9'
end function
function separateHouseNumber(integer i)
string address = addresses[i]
sequence parts = split(address,no_empty:=true)
string street, house
integer h = 0
if length(parts)>1 then
string last = parts[$]
if isDigit(last[1]) then
h = 1
string penult = parts[$-1]
if length(parts)>2
and isDigit(penult[1])
and match("194",penult)!=1 then
h = 2
end if
elsif length(parts)>2 then
h = 2
end if
end if
if h then
street = join(parts[1..$-h])
house = join(parts[$-h+1..$])
else
street = join(parts)
house = "(none)"
end if
string colour = iff(mod(i,2)=0?"#d7fffe":"#9dbcd4")
return {colour,address,street,house}
end function
constant html_hdr = """
<html>
<head>
<title>Rosetta Code - Start a Web Browser</title>
<meta charset="UTF-8">
</head>
<body bgcolor="#d8dcd6">
<p align="center">
<font face="Arial, sans-serif" size="5">Split the house number from the street name</font>
</p>
<p align="center">
<table border="2"> <tr bgcolor="#02ccfe">
<th>Address</th><th>Street</th><th>House Number</th>
""",
html_line = """
<tr bgcolor=%s><td>%s</td><td>%s</td><td>%s</td></tr>
""",
html_ftr = """
</table>
</p>
</body>
</html>
"""
 
procedure main()
integer fn = open("test.html","w")
printf(fn,html_hdr)
for i=1 to length(addresses) do
printf(fn,html_line,separateHouseNumber(i))
end for
printf(fn,html_ftr)
close(fn)
system("test.html")
end procedure
main()</lang>
output as perl
 
=={{header|Racket}}==
7,794

edits