Sort records in perl

Google wasn't finding me what was obviously a simple one-liner in perl, so here's how to sort a list of records marked by stars and separated by some string (a $ in this example) in reverse order:

perl -e '$/="\$\n"; print sort {$b cmp $a} grep(/^\*/, <>);'

I used this to sort a list such as:

This is boring
Description of boring stuff.
$
* This is interesting
Description of interesting stuff.
$
** This is very interesting
Description of very interesting stuff.
$

etc.

Explanation:

$/="\$";

set record separator

print sort {$b cmp $a} grep(/\*/, <>);

read file (<>), create array of lines with stars (grep), sort in reverse (sort {$b cmp $a}), print resulting array

You can be creative with the record separator, grep pattern, sort function, etc.

Photos from India and Turkey

I'm in Bulgaria at the moment. Some photos from Turkey and from Arambol, Mumbai and Elora in India are online.

Two months on and it's... Turkey

India is receding. After a few days in beautiful Istanbul I'm taking a bus to Goreme, an eroded volcanic landscape with unusual human habitations carved into volcanic tuft. I hope to spot some wildflowers. The weather here is just about perfect. Istanbul is very crowded and has lots of mosques. My favorite area ended up being down by the water at Eminonu where you can get a big fish sandwich in a big chunk of bread handed over by men baking on rocking boats. Actually, it's a big tourist thing but the locals like the sandwiches too, so there must be something to it. I'm trying not to gorge on Turkish sweets and baklavas and such but it's hard to resist. Better get some food before the long bus ride.

Chronicles of Paes and Nunes

The text A Forgotten Empire (Vijayanagar): a contribution to the history of India is an amazing eye-witness account near the end of the Vijayanagar empire's rule in Vijayanagara, present-day Hampi. Written by the Portueguese Domingos Paes and Fernão Nunes about 1520 and 1535 and translated into English, a copy was available in a small bookshop located in the back of the Virupaksha temple, behind a room with a camera-obscura view of the temple's entry tower. The chronicles contain stunning information about how the king and people lived, a fabulously wealthy, capricious, brutal empire. I walk down the street in Hampi, where Paes describes walking to the Virupaksha temple--which may predate the empire and is still in use today--on a street lined with houses used by nobles; now the poor live there, sharing space with tourist trinket shops and Internet cafes. A child will walk up to you "hello, 10 rupee... chocolate? biscuit?" while a chicken crows in a tree. Dancing girls, human and animal sacrifice, wars, elephants slashing, self-immolation, taxes, bounty and wealth.

Highlight images

There are two new highlights albums: Good Highlights, containing nearly 800 (about 10%) of the better images uploaded from my travels, and Better Highlights, containing about 100 images out of the 800. You can look through these albums to see some of my more successful photographic moments, skipping all the more mundane pictures that made it into my main albums.

Pictures from India, Malaysia, Singapore, Australia

A selection of the last few months of pictures is up on my site. The gallery is still a work in progress. All the pictures were rearranged into folders based on geographic or administrative boundaries, i.e., world region, country, state, city (or area) and also renamed with a shorter identifier.

You can finally see the latter pictures from Australia, especially Kakadu National Park in the Northern Territory (I can't remember if these had been uploaded previously), Malaysia, and my second visit to India.

For India, the new pictures are from Tamil Nadu, Kerala, and Karnataka. I'm currently taking lots of pictures in Hampi.

Hillstations and parks

February 19, 2009: The goal today is Kodiakanal, a hill station town at an elevation of 2000 meters located a few hours from Madurai. From Rameswaram I go back to Madurai, where I stay one last night. In the morning I manage to have the absolute worst meal I can recall in India--forgetful, slow service all for the joy of tasting spoiled cheese and lousy dosai. The search for protein (egg, cheese) should, sometimes, take a back seat to eating at tried-and-proven restaurants. I take the bus up to Kodiakanal, about a 4 hour trip. It's a relatively pleasant ride with nice views as we ascend from the lower plains into the mountains, arriving at an altitude of 2000 m.

Site migrated to new host

My web site has been moved to a new hosting provider, though you probably won't be able to see much difference. My old provider, Cirtex Hosting was never quite satisfactory, for various reasons. My new provider is A2 Hosting. They provide the software I need (Linux, Mysql, PHP, shell access) for about $8/month and had the most reasonable terms of service of the competing providers I examined. I took this opportunity to recreate the gallery since the database had become corrupted, as well as to upgrade my Drupal instance. There are a few tweaks I'd like to apply but customizing the site turns out to be more hastle than it's worth, so, other than adjusting colors, it's running a basic install with a few extra modules.

Mysore and beyond

From Munnar I made it down to Alleppey and Cochin in Kerala, then up to Ooty. My recommendation is don't even spend a night in Ooty but go straight to Kotagiri. Then I came down to Mysore in Karnataka, another boring Indian city that LP makes sound charming--it's not, and the "palace" is overpriced and overdone, like burnt bread being passed off as tasty, though standing in Government House made me feel like I should have just ridden up in my proper British officer's uniform while the director yelled "ACTION!". From here it's on to Madikeri for the mountains, Hassan for the temples, and then Hampi to bake in the heat and admire the ruins of an ancient civilization--our future. My only regret is that Mudumalai sanctuary is closed for the dry season and I can't figure out the other parks south of Mysore through which the bus drove and look wonderful, down to the peacock standing 5 meters up on a branch and calling out across the dry, burnt land, as if the ashes had gathered themselves into his folded dark green tail and hung again like leaves. His call reverberated across the quiescent landscape, summoning--soon, the pea hen, and his feathers unfolding, iridescent in the sun, leaves bursting from prisons of bark, traceries of veins pulsing with the blood of life, water.

To Munnar and beyond

Tomorrow I try for Munnar again, from whence a couple of nearby nature reserves can be visited: Eravikulam National Park and Chinnar Wildlife Sanctuary. It may be possible to stay in or near Chinnar. Getting to Munnar from Kodiakanal is not as simple as hoped. Though there is a direct road between the two towns, there is no direct bus service. Instead, you have to take a bus (twice a day, 11:45 and 14:15) to Thane, directly south of Kodiakanal, then catch another bus to Munnar. It will be several hours, essentially another day lost to inefficient travel. After the parks, it's backtracking to Munnar, then into Kerala, where I'll see Kochi and then Alleppey for some backwater touring, then back up to Kochi and, via Pollachi to Indira Gandhi NP, then via Combiatore to Silent Valley NP and then the Ooty hill station town. After Kerala it will be on to Karnataka, where my primary goal is the ruins at Hampi, though I have just been told that Karnataka has great food, good transport, is cheap, and has lots of good things to see.

Noise and myth in Rameswaram

February 18 2009: Today it's off to Rameswaram, an important pilgrimage town on an island close to Sri Lanka. The site is tied to a story about Rama, his battles to vanquish a Sri Lanka ruler, and his rescue of his maiden. The bus ride takes 4 hours, costs inr$50, then a short ride on a local bus for inr$2. It takes me over an hour to find a hotel. The places recommended in the LP are overpriced--inr$500 and up and/or fully booked. The touts are annoying and won't leave me alone, so I try a different tack: stick my fingers in my ears and go la la la la. It works, they leave me alone. I walk along the shore. Cows are shitting, Indians are bathing. I get led to what is promised to be a nice quiet place, but it lacks anything that looks like a proper hotel--signage, desk--and I decide it's too dodgy and back out. Finally, I find Chola Hotel on North Car street with rooms for inr$195. It has a bucket shower and a tv. It's a Christian-run affair but behind the counter there are also pictures of Hindu gods. On the second floor there's a picture of Pope John Paul.

Lackluster temple of Madurai

February 16, 2009: the bus to madurai from trichy takes 3.5 (?) hours, costs inr$35. There are plenty of rickshaw drivers at the station but I take a bus to the temple area for inr$7. Hotel Thilaga has a room for inr$190. If you stay there, try for one of the rooms on the inside--they're dark but you won't be kept up by the noise from next-door surya hotel's ac motors. I have a tasty dinner served with a smile. A paneer masala dosai garnished with coconut chutney is one of my favorite south Indian dishes. Picking up mouthwash, the storekeeper says he has a brother who works as a doctor in Boston. I walk down to the Meenkashi temple. On the way a tout tries to get me to go into a tailor shop, makes up all sorts of gibberish about the temple being closed for a festival and about his being an English teacher who's just walking back to his home. I just keep on walking to the temple entrance.

Trichy

Trichy

february 13-14, 2009: Trichy is, surprise surprise, noisy. A fellow tourist points me toward vijay hotel, opposite the bus station, where I get a room with tv for inr$235. I feel much better after a proper meal: enough of missed idli meals. Trichy has a few temples to visit. The Rock Fort temple is perched atop a large rock outcrop and provides good views of the city. Sri Ranganathaswamy temple is noted for the seven gates that lead to its center. I'm tired the next day and though I get to the Rock Fort temple early the prospect of walking up 400+ steps in my bare feet with a sore blister is disheartening so I head back to the room and rest. Along the way I pass a large sign advertising various computer services: Java, .NET, C/C++, etc. There are lots of signs around this area, from Chennai on, advertising either courses or services in this field.

Antelope and eagles in Kodiakarai

February 10, 2009: Kodiakarai is the town adjacent to the Point Calimere Wildlife Sanctuary, located on the Coromandel Coast of southern India. This is the same coast Columbus set out to find when he stumbled into America. They still grow delicious black pepper which they add liberally to tasty chutnis. The sanctuary protects varied birdlife, blackbuck antelope, and spotted deer.

The Lonely Elephant of Thanjavur

February 8 2009: Thanjavur is another noisy, dusty indian town. Walking to a hotel, I cross a filthy, polluted river and wander on to Raja's Guesthouse. This is set back a bit from the road and promises to be a bit quieter than some of the other options. A large courtyard is surrounded by a one-story set of rooms, similar in layout to an American road motel. The courtyard and gardens haven't been touched in a while, but their pattern suggests former glories. The rooms are grungy and filthy. The lime green paint is covered with layers of dirt from years and years of use. The windows are dusty. Everything is grungy. Later I find mouse droppings on the bed and in the room. Yuck. In back, a dirty garden area separates what becomes some kind of combined loud Hindi music with announcements booming and echoing from loudspeakers. Mercifully this ceases at night. The Lonely Planet actually recommends this dump, but in my opinion it is unfit for use. I checked out the next morning and switched to the much nicer hotel Tamil Nadu, which is right next door.

Temples of Darasuram and Gangaikondacholisvaram

February 7, 2009: In the morning, before leaving Puducherry, I stop by for a quick consult with a doctor for the princely sum of inr$100 (usd$2)--the upshot is my foot is doing fine (see my earlier post about cellulitis). Getting to the doctor proved more perplexing than anticipated, as it involved a brief conversation with the stupidest rickshaw driver in the world. Imagine, if you will, a man, seated in his green and yellow rickshaw--the poor man's taxi--on a busy street corner in the middle of the morning. Approaching this keen businessman is a tourist, decked out in suitable obvious tourist garb: hat, funny clothes, giant bags of who-knows-what; in short, someone saying "I have money and I want to spend it here". Said tourist walks up to said businessman and asks to be taken to such-and-such a location on so-and-so street. The expected, normal, progression is then "yes", followed by resolution of minor pricing details. What instead occured was a perplexing attempt to explain that a: said tourist was attempting to hire the rickshaw; b: said tourist was attempting to indicate the location to which he wanted to be taken.

Ritual in Chidambaram

February 6th 2009: In the morning it's on to Chidambaram to see more of the incredible temples scattered across Tamil Nadu as memories of great extravagance, gifts from the past. For the first half of the ride I sit facing forward, watching the scenery glide past the driver, disliking the horn that blasts my ears every few minutes. Giving my seat up, I sit on the engine cover and look back at the passengers. Their eyes look vacantly forward, waiting for their ordeal of travel to end. Their beautiful eyes look forward, oval shapes like Indian paintings, sculptures in flesh from glories of past days.

Searching for food in Puducherry

February 3rd 2009: I arrive in Puducherry at 7 pm, just 7 hours after leaving Mamallapuram. Such fun. The Lonely Planet guidebook says the bus station is 500 meters outside of town. Actually it's smack dab in the city, but perhaps 3 kilometers from the French colonial tourist-area. It takes me another hour of walking to get to the guesthouses. I stay at Surya Swastik guest house in a single room for just inr$100. The guidebook makes it sound drab: "you get what you pay for", but actually I quite like the old building and the rooms are perfectly clean, though I ask for a cleaner bed sheet. There are even hooks to attach a bednet, a rarity in Indian hotels. I find dinner and pick up a few Indian sweets at a busy shop on Nehru road--the closest thing I could find to a birthday cake at this hour.

Relaxing in Mamallapuram

January 30 2009: Mamallapuram is a world-heritage listed site with beautiful stone carvings made around 600-700 ce. From the UNESCO listing:

"This group of sanctuaries, founded by the pallava kings, was carved out of rock along the Coromandel coast in the 7th and 8th centuries. It is known especially for its rathas (temples in the form of chariots), mandapas (cave sanctuaries), giant open-air reliefs such as the famous 'descent of the ganges', and the temple of Rivage, with thousands of sculptures to the glory of Shiva"

Scurrying in Chennai

January 29th 2009: The next day I am very tired and manage to do nothing other than find another nicer and cheaper guesthouse, the Broadlands. The room is nice and just INR$300. A simple bed, a fluorescent lamp, a fan, a louvered door and curtain, bare tiled roof. It is all painted in pale blue, every fixture, everything from the walls to the ceiling, even the bed and pillow are covered in denim that has seen its share of washings. Dark cement floors with dirt that stains my feet, the toilet is dark, it is old and worn, like old clothing the room feels comfortable. Bare hinges hold a place for a door made only of air, the room is open to a small enclosed porch. A small writing desk, chair, a mirror sits above the desk. I sit and work with my photographs, the mirror staring back at myself. Another chair and round table complete the porch, whose shuttered and barred windows are painted from the same infinite bucket of blue paint. A central courtyard completes the scene. The only drawback is that the room faces a road and, this being India, I wake many times during the night from sounds of clanging, honking, barking, padding feet.