NAME
Clownfish::Util - Miscellaneous helper functions.
DESCRIPTION
Clownfish::Util provides a few convenience functions used internally by other Clownfish modules.
FUNCTIONS
slurp_file
my $foo_contents = slurp_file('foo.txt');
Open a file, read it in, return its contents. Assumes either binary data or text with an encoding of Latin-1.
current
compile('foo.c') unless current( 'foo.c', 'foo.o' );
Given two elements, which may be either scalars or arrays, verify that everything in the second group exists and was created later than anything in the first group.
verify_args
verify_args( \%defaults, @_ ) or confess $@;
Verify that named parameters exist in a defaults hash. Returns false and sets $@ if a problem is detected.
strip_c_comments
my $c_minus_comments = strip_c_comments($c_source_code);
Quick 'n' dirty stripping of C comments. Will massacre stuff like comments embedded in string literals, so watch out.
write_if_changed
write_if_changed( $path, $content );
Test whether there's a file at $path
which already matches $content
exactly. If something has changed, write the file. Otherwise do nothing (and avoid bumping the file's modification time).
COPYRIGHT AND LICENSE
Copyright 2008-2011 Marvin Humphrey
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.