Data-Table-Text

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    is_deeply [sort values %$ra], [sort values %$rb];

    unlink $a2;
    mergeFolder($a, $b);
    ok -e $b1; ok  -e $b2;

    copyFolder($a, $b);
    ok -e $b1; ok !-e $b2;

    copyFile($a1, $a2);
    ok readFile($a1) eq readFile($a2);

    writeFiles($files);
    ok !moveFileNoClobber  ($a1, $a2);
    ok  moveFileWithClobber($a1, $a2);
    ok !-e $a1;
    ok readFile($a2) eq q(1111);
    ok  moveFileNoClobber  ($a2, $a1);
    ok !-e $a2;
    ok readFile($a1) eq q(1111);

    clearFolder(q(aaa), 11);
    clearFolder(q(bbb), 11);

### includeFiles($expand)

Read the given file and expand all lines that start "includeThisFile " with the file named by the rest of the line and keep doing this until all the included files have been expanded or a repetition is detected.  Returns the expanded file or confesse...

       Parameter  Description
    1  $expand    File to expand

**Example:**

    if (1)
     {my $d = temporaryFolder;
      my $a = "$d/a.txt";
      my $b = "$d/b.txt";
      my %d = ($a => <<END,
    aaa
    includeThisFile $d/b.txt
    ccc
    END
               $b => <<END,
    bbb
    END
      );

      writeFiles(\%d);

      is_deeply [includeFiles($a)], ["aaa
  ", "bbb
  ", "ccc
  "];  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

      unlink $a, $b;
     }

### appendFile  ($file, $string)

Append to **$file** a **$string** of [Unicode](https://en.wikipedia.org/wiki/Unicode) content encoded with [utf8](https://en.wikipedia.org/wiki/UTF-8), creating the $file first if necessary. Return the name of the $file on success else confess. The $...

       Parameter  Description
    1  $file      File to append to
    2  $string    String to append

**Example:**

    my $f = writeFile(undef,  "aaa");
    is_deeply [readFile $f], ["aaa"];


    appendFile($f, "bbb");  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

    is_deeply [readFile $f], ["aaabbb"];

    my $F = writeTempFile(qw(aaa bbb));
    is_deeply [readFile $F], ["aaa
", "bbb
"];

    eval {writeFile($f,  q(ccc))};
    ok $@ =~ m(File already exists:)i;

    overWriteFile($F,    q(ccc));
    ok   readFile($F) eq q(ccc);

    unlink $f, $F;

### createEmptyFile ($file)

Create an empty file unless the file already exists and return the name of the file else confess if the file cannot be created.

       Parameter  Description
    1  $file      File to create or B<undef> for a temporary file

**Example:**

    my $D = temporaryFolder;
    ok  -d $D;

    my $d = fpd($D, q(ddd));
    ok !-d $d;


    my @f = map {createEmptyFile(fpe($d, $_, qw(txt)))} qw(a b c);  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

    is_deeply [sort map {fne $_} findFiles($d, qr(txt\Z))], [qw(a.txt b.txt c.txt)];

    my @D = findDirs($D);
    my @e = ($D, $d);
    my @E = sort @e;
    is_deeply [@D], [@E];

    is_deeply [sort map {fne $_} searchDirectoryTreesForMatchingFiles($d)],
              ["a.txt", "b.txt", "c.txt"];

    is_deeply [sort map {fne $_} fileList(prefferedFileName "$d/*.txt")],
              ["a.txt", "b.txt", "c.txt"];

    ok -e $_ for @f;



( run in 0.795 second using v1.01-cache-2.11-cpan-39bf76dae61 )