Clownfish::Util - Miscellaneous helper functions.
Clownfish::Util provides a few convenience functions used internally by other Clownfish modules.
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.
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( \%defaults, @_ ) or confess $@;
Verify that named parameters exist in a defaults hash. Returns false and sets $@ if a problem is detected.
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( $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).
$path
$content
Copyright 2008-2010 Marvin Humphrey
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install KSx::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm KSx::Simple
CPAN shell
perl -MCPAN -e shell install KSx::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.