APM: YAML url mappings
Sam Foster
austin.pm at sam-i-am.com
Wed Sep 22 13:16:29 CDT 2004
So, after this month's very intersting YAML presentation, I thought I'd
give it a whirl with a little 404 handler I'm making. It needs to
attempt to lookup a (bad) url, or fragment of the url in a simple old =>
new hash structure, eg
{
'/some/old/url.html' => '/new/location/for/url.html',
'/old/dir' => '/new/dir'
}
Having a nice (safe) human editable datafile to store this would be
ideal.. a nice spot for YAML I thought.
Except the obvious doesn't work:
---
/some/old/url.html: /new/location/for/url.html
/old/dir: /new/dir
it doesn't like '/' as a starting character (or '~,' or '.'. Is it
matching with something like /\s*\w+/ ?.. must take a look.)
I looked through the YAML perldocs, and the spec and found nothing about
illegal or allowed characters that might explain this. Does that make it
a bug? Anyone have any thoughts, workarounds or suggestions?
Right now, I've prepended 'ROOT' so I get
---
ROOT/some/old/url.html: ROOT/new/location/for/url.html
which works just fine - and I strip it back off before I return the url
to the user... But kind of dirties my data a little. The goal is to keep
the data format clean and intuitive, and leave any complexity in the
script. I can obviously write my own "parser" or use Config::Auto or
something else.. but I've just been telling everyone at work all about
YAML and need to not look silly :)
thanks,
Sam
More information about the Austin
mailing list