Acme-Cow-Interpreter
view release on metacpan or search on metacpan
bin/text2cow.pl view on Meta::CPAN
#!/usr/bin/perl
#
# text2cow - prints Cow source code that prints a given text
################################################################################
## Modules and package variables.
################################################################################
use strict; # restrict unsafe constructs
use warnings; # control optional warnings
use File::Basename (); # split a pathname into pieces
use Getopt::Std (); # process single-character command line options
# Initialize option variables.
our $opt_h;
our $opt_v;
################################################################################
## File-private lexical variables.
################################################################################
my $VERSION = '0.002'; # program version
my $PROGNAME = File::Basename::basename($0); # program name
my $ncmd_on_line = 0; # number of command written on current line
################################################################################
## Subroutines.
################################################################################
################################################################################
# print_version
#
# Print program version and copyright information.
#
sub print_version () {
print <<"EOF" or die "$PROGNAME: print failed: $!\n";
$PROGNAME $VERSION
Copyright 2007-2020 Peter John Acklam.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
EOF
}
################################################################################
# print_usage
#
# Print program usage.
#
sub print_usage () {
print <<"EOF" or die "$PROGNAME: print failed: $!\n";
Usage: $PROGNAME [programfile]
Prints Cow source code that, when executed, prints a given text.
-h print usage and exit
-v print version information and exit
If file is omitted, text is read through the standard input.
Example: \$ printf 'Hello, World!\\n' | $PROGNAME > hello.cow
\$ cow hello.cow
Hello, World!
Report bugs to <pjacklam\@gmail.com>.
EOF
}
################################################################################
( run in 2.028 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )