Data-Table-Text

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    my @g = fileList(qq($D/*/*.txt));
    ok @g == 3;

    clearFolder($D, 5);
    ok onWindows ? 1 : !-e $_ for @f;
    ok onWindows ? 1 : !-d $D;

### setPermissionsForFile   ($file, $permissions)

Apply [chmod](https://linux.die.net/man/1/chmod) to a **$file** to set its **$permissions**.

       Parameter     Description
    1  $file         File
    2  $permissions  Permissions settings per chmod

**Example:**

    if (1)
     {my $f = temporaryFile();

      setPermissionsForFile($f, q(ugo=r));  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

      my $a = qx(ls -la $f);
      ok $a =~ m(-r--r--r--)s;

README.md  view on Meta::CPAN

362 [setPartitionOnIntersectionOverUnion](#setpartitiononintersectionoverunion) - Partition, at a level of **$confidence** between 0 and 1, a set of sets **@sets** so that within each partition the [setIntersectionOverUnion](#setintersectionoverunion...

363 [setPartitionOnIntersectionOverUnionOfHashStringSets](#setpartitiononintersectionoverunionofhashstringsets) - Partition, at a level of **$confidence** between 0 and 1, a set of sets **$hashSet** represented by a hash, each hash value being a stri...

364 [setPartitionOnIntersectionOverUnionOfHashStringSetsInParallel](#setpartitiononintersectionoverunionofhashstringsetsinparallel) - Partition, at a level of **$confidence** between 0 and 1, a set of sets **$hashSet** represented by a hash, each has...

365 [setPartitionOnIntersectionOverUnionOfSetsOfWords](#setpartitiononintersectionoverunionofsetsofwords) - Partition, at a level of **$confidence** between 0 and 1, a set of sets **@sets** of words so that within each partition the [setIntersectionO...

366 [setPartitionOnIntersectionOverUnionOfStringSets](#setpartitiononintersectionoverunionofstringsets) - Partition, at a level of **$confidence** between 0 and 1, a set of sets **@strings**, each set represented by a string containing words and punc...

367 [setPermissionsForFile](#setpermissionsforfile) - Apply [chmod](https://linux.die.net/man/1/chmod) to a **$file** to set its **$permissions**.

368 [setUnion](#setunion) - Union of sets **@s** represented as arrays of strings and/or the keys of hashes.

369 [showGotVersusWanted](#showgotversuswanted) - Show the difference between the wanted string and the wanted string.

370 [showHashes](#showhashes) - Create a map of all the keys within all the hashes within a tower of data structures.

371 [showHashes2](#showhashes2) - Create a map of all the keys within all the hashes within a tower of data structures.

372 [spellCheck](#spellcheck) - Spell checker

lib/Data/Table/Text.pm  view on Meta::CPAN

  print  {$F} '';
  close  ($F);
  -e $file or confess "Failed to create empty file:\n$file\n";
  $file                                                                         # Return file name on success
 } # createEmptyFile

sub binModeAllUtf8                                                              #P Set STDOUT and STDERR to accept utf8 without complaint.
 {binmode $_, ":utf8" for *STDOUT, *STDERR;
 }

sub setPermissionsForFile($$)                                                   # Apply L<chmod> to a B<$file> to set its B<$permissions>.
 {my ($file, $permissions) = @_;                                                # File, permissions settings per chmod
  return undef unless confirmHasCommandLineCommand(q(chmod));                   # Confirm we have chmod
  qx(chmod $permissions $file);                                                 # Use chmod to set permissions
 }

sub numberOfLinesInFile($)                                                      # Return the number of lines in a file.
 {my ($file) = @_;                                                              # File
  scalar split /\n/, readFile($file);                                           # Number of lines
 } # numberOfLinesInFile

sub overWriteHtmlFile($$)                                                       # Write an L<html> file to /var/www/html and make it readable.
 {my ($file, $data) = @_;                                                       # Target file relative to /var/www/html, data to write
  my $s = writeTempFile($data);
  my $t = fpf(q(/var/www/html/), $file);
  xxx qq(sudo mv $s $t; chmod o+r $t);
  unlink $s;
 }

sub overWritePerlCgiFile($$)                                                    # Write a L<Perl> file to /usr/lib/cgi-bin and make it executable after checking it for syntax errors.
 {my ($file, $data) = @_;                                                       # Target file relative to /var/www/html, data to write
  my $s = writeTempFile($data);
  my $r = qx(perl -c $s 2>&1);
  if ($r =~ m(syntax OK)si)
   {my $t = fpf(q(/usr/lib/cgi-bin/), $file);
    say STDERR qx(sudo mv $s $t; chmod o+rx $t);
   }
  else
   {my @data = map {[$_]} split m/\n/, $data;
    say STDERR formatTable([@data]);
    confess "Perl error:\n$r\n";
   }
  unlink $s;
 }

#D2 Copy                                                                        # Copy files and folders. The B<\Acopy.*Md5Normalized.*\Z> methods can be used to ensure that files have collision proof names that collapse duplicate content even when c...

lib/Data/Table/Text.pm  view on Meta::CPAN

END
   }

  push @code, <<END;
  printf("}\\n");
  return 0;
 }
END
  my $C = &getCCompiler;                                                        # Get C compiler
  my $c = owf(q(zzzTemporary.c), join "\n", @code);                             # Write and run a program to get the values
  my $r = eval qx($C $c; chmod ugo+x a.out; ./a.out; rm a.out);
  unlink $c;
  for my $c(sort keys %$r)                                                      # Update known constants
   {$o{$c} = $getSystemConstantsFromIncludeFile{$c} = $$r{$c}
   }

  %o
 }

my %getStructureSizeFromIncludeFile;                                            # Cache system structure sizes

lib/Data/Table/Text.pm  view on Meta::CPAN

#include <$file>
#include <stdio.h>
int main(void) {
  printf("%ld\\n", (long)sizeof($structure));
  return 0;
 }
END

  my $C = &getCCompiler;                                                        # Get C compiler
  my $c = owf(q(zzzTemporary.c), join "\n", @code);                             # Write and run a program to get the values
  my $r = eval qx($C $c; chmod ugo+x a.out; ./a.out; rm a.out);
  $getStructureSizeFromIncludeFile{$c} = $r;
 }

my %getFieldOffsetInStructureFromIncludeFile;                                   # Cache system field offsets

sub getFieldOffsetInStructureFromIncludeFile($$$)                               # Get the offset of a field in a system structures from an include file.
 {my ($file, $structure, $field) = @_;                                          # File to read, structure name, field name

  return      $getFieldOffsetInStructureFromIncludeFile{$structure}
    if exists $getFieldOffsetInStructureFromIncludeFile{$structure};

lib/Data/Table/Text.pm  view on Meta::CPAN

#include <$file>
#include <stdio.h>
int main(void) {
  printf("%ld\\n", (long)&((($structure *)0)->$field));
  return 0;
 }
END

  my $C = &getCCompiler;                                                        # Get C compiler
  my $c = owf(q(zzzTemporary.c), join "\n", @code);                             # Write and run a program to get the values
  my $r = eval qx($C $c; chmod ugo+x a.out; ./a.out; rm a.out);
  $getFieldOffsetInStructureFromIncludeFile{$c} = $r;
 }

#D1 Unix domain communications                                                  # Send messages between processes via a unix domain socket.

sub newUdsr(@)                                                                  #P Create a communicator - a means to communicate between processes on the same machine via L<Udsr::read|/Udsr::read> and L<Udsr::write|/Udsr::write>.
 {my (@parms) = @_;                                                             # Attributes per L<Udsr Definition|/Udsr Definition>
   my $u = genHash(q(Udsr),                                                     # Package name
    client       => undef,                                                      # Client socket and connection socket
    headerLength => 8,                                                          #I Length of fixed header which carries the length of the following message

lib/Data/Table/Text.pm  view on Meta::CPAN

    @_
   );
 }

sub newUdsrServer(@)                                                            # Create a communications server - a means to communicate between processes on the same machine via L<Udsr::read|/Udsr::read> and L<Udsr::write|/Udsr::write>.
 {my (@parms) = @_;                                                             # Attributes per L<Udsr Definition|/Udsr Definition>
  my $u = newUdsr(@_);
  my $f = $u->socketPath;
  unlink $f;
  my $s = IO::Socket::UNIX->new(Type=>SOCK_STREAM(), Local=>$f, Listen=>1);     # Create socket
  xxx(qq(chmod ugo=rwx $f));                                                    # Ensure that www-data can read and write to the socket
# lll "Created unix domain socket as user:", qx(/usr/bin/whoami);
  if (my $pid = fork)                                                           # Run the server in a process by itself
   {$u->serverPid = $pid;                                                       # Record server pid so it can be killed
    return $u;
   }
  else                                                                          # Run the server action on a client connection
   {while (my $con = $s->accept())
     {$u->client = $con;
      call sub{$u->serverAction->($u)};                                         # The server action sub should use the read and write routines in the passed communicator to interact with the client .
      $con->close;

lib/Data/Table/Text.pm  view on Meta::CPAN

    carbonDioxide   => [q(carbon dioxide),                                      "https://en.wikipedia.org/wiki/Carbon_dioxide"                                                                                    ],
    cauchy          => [q(Augustin Louis Cauchy),                               "https://en.wikipedia.org/wiki/Augustin-Louis_Cauchy"                                                                             ],
    cdk             => [q(cloud development kit),                               "https://aws.amazon.com/cdk/"                                                                                                     ],
    certbot         => [q(Certbot),                                             "https://certbot.eff.org/lets-encrypt/ubuntufocal-apache"                                                                         ],
    cgi             => [q(Common Gateway Interface),                            "https://en.wikipedia.org/wiki/Common_Gateway_Interface"                                                                          ],
    chartjs         => [q(Chart.js),                                            "https://www.chartjs.org/"                                                                                                        ],
    chatgpt         => [q(Chat GPT),                                            "https://platform.openai.com/docs/guides/text-generation"                                                                         ],
    china           => [q(Made In China),                                       "https://www.made-in-china.com/"                                                                                                  ],
    siliconChip     => [q(chip),                                                "https://en.wikipedia.org/wiki/Integrated_circuit"                                                                                ],
    chips           => [q(chips),                                               "https://en.wikipedia.org/wiki/Integrated_circuit"                                                                                ],
    chmod           => [q(chmod),                                               "https://linux.die.net/man/1/chmod"                                                                                               ],
    chown           => [q(chown),                                               "https://linux.die.net/man/1/chown"                                                                                               ],
    cicd            => [q(CI/CD),                                               "https://en.wikipedia.org/wiki/Continuous_integration"                                                                            ],
    CICS            => [q(CICS),                                                "https://en.wikipedia.org/wiki/CICS"                                                                                              ],
    cicero          => [q("The sinews of war are an infinite supply of money"), "https://en.wikipedia.org/wiki/Cicero#Legacy"                                                                                     ],
    cloudComputing  => [q(Cloud Computing),                                     "https://en.wikipedia.org/wiki/Cloud_computing"                                                                                   ],
    co2             => [q(Carbon Dioxide),                                      "https://en.wikipedia.org/wiki/Carbon_dioxide"                                                                                    ],
    codeMentor      => [q(Code Mentor),                                         "https://www.codementor.io/"                                                                                                      ],
    codementor      => [q(Codementor),                                          'https://www.codementor.io/@philiprbrenan'                                                                                        ],
    codeMentor      => [q(Codementor),                                          'https://www.codementor.io/@philiprbrenan'                                                                                        ],
    code            => [q(code),                                                "https://en.wikipedia.org/wiki/Computer_program"                                                                                  ],

lib/Data/Table/Text.pm  view on Meta::CPAN

    my @g = fileList(qq($D/*/*.txt));
    ok @g == 3;

    clearFolder($D, 5);
    ok onWindows ? 1 : !-e $_ for @f;
    ok onWindows ? 1 : !-d $D;


=head3 setPermissionsForFile   ($file, $permissions)

Apply L<chmod|https://linux.die.net/man/1/chmod> to a B<$file> to set its B<$permissions>.

     Parameter     Description
  1  $file         File
  2  $permissions  Permissions settings per chmod

B<Example:>


  if (1)
   {my $f = temporaryFile();

    setPermissionsForFile($f, q(ugo=r));  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

    my $a = qx(ls -la $f);

lib/Data/Table/Text.pm  view on Meta::CPAN

362 L<setPartitionOnIntersectionOverUnion|/setPartitionOnIntersectionOverUnion> - Partition, at a level of B<$confidence> between 0 and 1, a set of sets B<@sets> so that within each partition the L<setIntersectionOverUnion|/setIntersectionOverUnion> ...

363 L<setPartitionOnIntersectionOverUnionOfHashStringSets|/setPartitionOnIntersectionOverUnionOfHashStringSets> - Partition, at a level of B<$confidence> between 0 and 1, a set of sets B<$hashSet> represented by a hash, each hash value being a string...

364 L<setPartitionOnIntersectionOverUnionOfHashStringSetsInParallel|/setPartitionOnIntersectionOverUnionOfHashStringSetsInParallel> - Partition, at a level of B<$confidence> between 0 and 1, a set of sets B<$hashSet> represented by a hash, each hash ...

365 L<setPartitionOnIntersectionOverUnionOfSetsOfWords|/setPartitionOnIntersectionOverUnionOfSetsOfWords> - Partition, at a level of B<$confidence> between 0 and 1, a set of sets B<@sets> of words so that within each partition the L<setIntersectionOv...

366 L<setPartitionOnIntersectionOverUnionOfStringSets|/setPartitionOnIntersectionOverUnionOfStringSets> - Partition, at a level of B<$confidence> between 0 and 1, a set of sets B<@strings>, each set represented by a string containing words and punctu...

367 L<setPermissionsForFile|/setPermissionsForFile> - Apply L<chmod|https://linux.die.net/man/1/chmod> to a B<$file> to set its B<$permissions>.

368 L<setUnion|/setUnion> - Union of sets B<@s> represented as arrays of strings and/or the keys of hashes.

369 L<showGotVersusWanted|/showGotVersusWanted> - Show the difference between the wanted string and the wanted string.

370 L<showHashes|/showHashes> - Create a map of all the keys within all the hashes within a tower of data structures.

371 L<showHashes2|/showHashes2> - Create a map of all the keys within all the hashes within a tower of data structures.

372 L<spellCheck|/spellCheck> - Spell checker



( run in 0.240 second using v1.01-cache-2.11-cpan-496ff517765 )