| 1 | package FindApp::Utils::Misc; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use FindApp::Utils::Assert ":all"; | ||
| 8 | use FindApp::Utils::Foreign ":Scalar::Util"; | ||
| 9 | |||
| 10 | ################################################################# | ||
| 11 | |||
| 12 | sub is_csh ( ) ; | ||
| 13 | sub n_times ( _ ) ; | ||
| 14 | |||
| 15 | ################################################################# | ||
| 16 | |||
| 17 | use Exporter qw(import); | ||
| 18 | our $VERSION = v1.0; | ||
| 19 | our @EXPORT_OK = qw( | ||
| 20 | is_csh | ||
| 21 | n_times | ||
| 22 | ); | ||
| 23 | our %EXPORT_TAGS = ( | ||
| 24 | all => \@EXPORT_OK, | ||
| 25 | ); | ||
| 26 | |||
| 27 | ################################################################# | ||
| 28 | |||
| 29 | sub is_csh() { | ||
| 30 | state $is_csh = do { | ||
| 31 | my $parent = getppid(); | ||
| 32 | `ps c$parent` =~ /t?[c-]sh\b/; | ||
| 33 | }; | ||
| 34 | return $is_csh; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub n_times(_) { | ||
| 38 | good_args(@_ == 1); | ||
| 39 | my($n) = @_; | ||
| 40 | looks_like_number($n) || croak("n_times argument should be a number, not $n"); | ||
| 41 | return "never" unless $n; | ||
| 42 | return "once" if $n == 1; | ||
| 43 | return "twice" if $n == 2; | ||
| 44 | return "thrice" if $n == 3; | ||
| 45 | return "$n times"; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; | ||
| 49 | |||
| 50 | =encoding utf8 | ||
| 51 | |||
| 52 | =head1 NAME | ||
| 53 | |||
| 54 | FindApp::Utils::Misc - FIXME | ||
| 55 | |||
| 56 | =head1 SYNOPSIS | ||
| 57 | |||
| 58 | use FindApp::Utils::Misc; | ||
| 59 | |||
| 60 | =head1 DESCRIPTION | ||
| 61 | |||
| 62 | =head2 Public Methods | ||
| 63 | |||
| 64 | =over | ||
| 65 | |||
| 66 | =item FIXME | ||
| 67 | |||
| 68 | =back | ||
| 69 | |||
| 70 | =head2 Exports | ||
| 71 | |||
| 72 | =over | ||
| 73 | |||
| 74 | =item FIXME | ||
| 75 | |||
| 76 | =item is_csh | ||
| 77 | |||
| 78 | =item n_times | ||
| 79 | |||
| 80 | =back | ||
| 81 | |||
| 82 | =head1 EXAMPLES | ||
| 83 | |||
| 84 | =head1 ENVIRONMENT | ||
| 85 | |||
| 86 | =head1 SEE ALSO | ||
| 87 | |||
| 88 | =over | ||
| 89 | |||
| 90 | =item L<FindApp> | ||
| 91 | |||
| 92 | =back | ||
| 93 | |||
| 94 | =head1 CAVEATS AND PROVISOS | ||
| 95 | |||
| 96 | =head1 BUGS AND LIMITATIONS | ||
| 97 | |||
| 98 | =head1 HISTORY | ||
| 99 | |||
| 100 | =head1 AUTHOR | ||
| 101 | |||
| 102 | Tom Christiansen << <tchrist@perl.com> >> | ||
| 103 | |||
| 104 | =head1 LICENCE AND COPYRIGHT | ||
| 105 | |||
| 106 | Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>. | ||
| 107 | All Rights Reserved. | ||
| 108 | |||
| 109 | This module is free software; you can redistribute it and/or | ||
| 110 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||
| 111 | |||
| 112 | =cut | ||
| 113 |