Re: Converting MARC fields with Catmandu - 'unless exists' failing.

2014-06-12 Thread Robin Sheat
Patrick Hochstenbach schreef op wo 11-06-2014 om 07:44 [+0200]:
 You just might need to upgrade your Catmandu (cpan Catmandu) to get the 
 fixed. You are probably using 0.9* syntax features with an older version of 
 Catmandu.

Ah, turns out I was on an 0.8 version, from around a month ago.

Unfortunately building the new version is going to be difficult as it
requires YAML::XS, and that has some /weird/ build conditions, like
requiring to be in a git repo and a specific branch. I'll see how I go.

 You might want to join our librecat-dev mailing list where we regulary post 
 update and discuss technicall issues:
 
 http://mail.librecat.org/mailman/listinfo/librecat-dev 

Cheers, I'll do that.

-- 
Robin Sheat
Catalyst IT Ltd.
✆ +64 4 803 2204
GPG: 5FA7 4B49 1E4D CAA4 4C38  8505 77F5 B724 F871 3BDF


signature.asc
Description: This is a digitally signed message part


Converting MARC fields with Catmandu - 'unless exists' failing.

2014-06-10 Thread Robin Sheat
I'm attempting to have a fixer that says if this field hasn't already
been set, set it to 0, so I have:

unless exists('onloan')
   add_field('onloan', '0')
end

This causes the error:

can't load fix unless exists('onloan')
   add_field('onloan', '0')
end
: coercion for _fixer (constructor argument: fix) failed: Bareword found 
where operator expected at (eval 85) line 2, near )
   add_field

It's possibly of note that the following from the cheat sheet fails
also:

unless exists('oogly')
  upcase('foo') # foo = 'bar'
end

with the same form of error. (Also, that comment is probably incorrect.)

A related question:

When I have a fixer like this that is three lines long, and I'm passing
in an array of fixers to the Catmandu::Fix constructor, what do I do
with the multiline ones? Should it be three strings in the array, should
it one string all on one line, or should it be one string with embedded
newlines?

When I try the final option, I get the error:

Unsuccessful stat on filename containing newline at 
/usr/share/perl5/Catmandu/Fix/Loader.pm line 33.

which is a standard Perl exception when you do a file operation on a
string with a \n anywhere that fails. 

-- 
Robin Sheat
Catalyst IT Ltd.
✆ +64 4 803 2204
GPG: 5FA7 4B49 1E4D CAA4 4C38  8505 77F5 B724 F871 3BDF


signature.asc
Description: This is a digitally signed message part