"Fossies" - the Fresh Open Source Software Archive

Member "RPerl-5.002000/lib/RPerl/Test/Operator10NamedUnaryExists/program_10_good.pl" (29 Nov 2019, 1339 Bytes) of package /linux/misc/RPerl-5.002000.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env perl
    2 
    3 # [[[ PREPROCESSOR ]]]
    4 # <<< TYPE_CHECKING: ON >>>
    5 # <<< EXECUTE_SUCCESS: "have $key_does_exist = TRUE" >>>
    6 # <<< EXECUTE_SUCCESS: "have $key_does_not_exist = FALSE" >>>
    7 
    8 # [[[ HEADER ]]]
    9 use RPerl;
   10 use strict;
   11 use warnings;
   12 our $VERSION = 0.001_000;
   13 
   14 # [[[ CRITICS ]]]
   15 ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls)  # USER DEFAULT 1: allow numeric values & print operator
   16 ## no critic qw(RequireInterpolationOfMetachars)  # USER DEFAULT 2: allow single-quoted control characters & sigils
   17 
   18 # [[[ OPERATIONS ]]]
   19 
   20 # homogeneous 2-dimensional hash of arrays of integers
   21 # DEV NOTE: must be on single one to match auto-generated Perl::Tidy output code
   22 my integer_arrayref_hashref $foo = { key_0 => [ 0, 1, 2, 3, 4 ], key_1 => [ 5, 6, 7, 8, 9 ], key_2 => [ 0, -1, -2, -3, -4 ], key_3 => [ -5, -6, -7, -8, -9 ] };
   23 
   24 my string $key_valid     = 'key_0';
   25 my string $key_not_valid = 'key_X';
   26 my boolean $key_does_exist     = exists $foo->{$key_valid};
   27 my boolean $key_does_not_exist = exists $foo->{$key_not_valid};
   28 
   29 if ($key_does_exist) {
   30     print 'have $key_does_exist = TRUE', "\n";
   31 }
   32 else {
   33     print 'have $key_does_exist = FALSE', "\n";
   34 }
   35 
   36 if ($key_does_not_exist) {
   37     print 'have $key_does_not_exist = TRUE', "\n";
   38 }
   39 else {
   40     print 'have $key_does_not_exist = FALSE', "\n";
   41 }
   42 
   43