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

2014-06-11 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


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

2014-06-10 Thread Patrick Hochstenbach
Hi Robin

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.

As for you second question. Yes, in Catmandu 0.9* all these combinations will 
work:

my $fixer = Catmandu->fixer('do_this()', 'do_that()');
my $fixer = Catmandu->fixer(['do_this()', 'do_that()']);
my $fixer = Catmandu->fixer(fixer('name'); with 'name' as a section in a 
catmandu.yml configuration file

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 

Greetings from ELAG2014 in Bath
Patrick

From: Robin Sheat [ro...@catalyst.net.nz]
Sent: Wednesday, June 11, 2014 4:44 AM
To: perl4lib
Subject: Converting MARC fields with Catmandu - 'unless exists' failing.

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