Converting MARC fields with Catmandu - 'unless exists' failing.
[email protected] (Robin Sheat) Wed, 11 Jun 2014 14:44:22 +1200
| Newsgroups | perl.perl4lib |
|---|---|
| Organization | Catalyst IT Ltd. |
| Message-ID | <[email protected]> |
--=-MX9IkE0JN9RVClNbA2u2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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 foun=
d 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 =3D> '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/Catman=
du/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.=20
--=20
Robin Sheat
Catalyst IT Ltd.
=E2=9C=86 +64 4 803 2204
GPG: 5FA7 4B49 1E4D CAA4 4C38 8505 77F5 B724 F871 3BDF
--=-MX9IkE0JN9RVClNbA2u2
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQEcBAABCgAGBQJTl8KGAAoJEHf1tyT4cTvfdowIAKKhH+IGRTyDVE+V7EE8rfAa
Wh0Ujb168xcw/QE8rCKlsN4SBK6oAI8sPV7mneHCmkkcG6oJHvIYxCsc0SL5tcoT
b4uY5Bkbf3wHheE0H1iMKv1nPCc87TTpKIkDzBrKx2koJBHJY36s1W74cZB1OcqQ
S5YHXDCdHxyPXDxNlO/NEQIqS0ngEYi9sAlBGntN/TDYMVAv3CUt2OFwmCm3ssVA
jx1+RYt1HUa2BHHrTcY3aBQ7B2RCUUTNa3SDtXS6MGGXGjtDr0bzxyQRB/OBEI0R
V4vpqtKM9zVr6R9pwX7KBQlCmyb6703HqtRsBRCRYUdZAx3GaooasAu+Vfr2FBY=
=FNgn
-----END PGP SIGNATURE-----
--=-MX9IkE0JN9RVClNbA2u2--