I'm very grateful for 2 excellent responses. I've coded toward both haukex's and soonix's suggestions, and I haven't completely disentangled ideas that are still crowding out the good ones here. I think I can lay out what I've done, state a better specification, and outline the things that cause trouble.

I looked also at config1.pm and realized that my claim that I only had sensitive values in one file per workspace was false. My new specification for the copy to the temp directory is that any file that matches "config", then a number, a dot, and a "pm" shall not be copied. Meanwhile, I have a created a template file, config3.tmpl, that is of the form it needs to be less the definition of the hash, which is to be templated in. I don't see why Text::Template wouldn't be fine. The longer arc of my question is how to both to populate and depopulate such hashes. What makes it very difficult is that we seem to be acting on perl syntax itself.

If we look haukex's output, the hash begins

$CONFIG = { my_github => {

, yet if we're to imitate the syntax in my source it begins:

our %config = ( my_sftp => {

I'm more than a little confused about what seem to be competing definitions of a hash.

$ cat config3.tmpl package config3; use Exporter qw(import); our @EXPORT = qw(%config); {$config_hash} 1; ---------- $ cat util2.pm package utils2; require Exporter; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( redact make_ini); sub redact{ use strict; use warnings; use 5.010; use Path::Tiny; my $file = shift; #use $file; resulted in error use config2; my $sub_hash = "my_github"; my $email = $config{$sub_hash}->{'email'}; my $password = $config{$sub_hash}->{'password'}; my $tempdir = Path::Tiny->tempdir('backup_XXXXXX'); say "temp dir is $tempdir"; my $scratch_file = $tempdir->child('batch_01', '1.manifest.txt')->touc +hpath; say "scratch_file is $scratch_file"; my $parent = $scratch_file->parent; say "parent is $parent"; chdir $tempdir unless $tempdir->subsumes(Path::Tiny->cwd); system("pwd"); use Data::Dumper; print Dumper \%config; my $b = "dummy"; return $b; } sub make_ini{ use strict; use warnings; use 5.010; use Path::Tiny; my $file = shift; use config2; use Config::Tiny; use Data::Dumper; my $path = shift; say "path is $path"; say "is the stuff here?"; print Dumper \%config; $config->write( $path, 'utf8' ); #this line draws error chdir "/home/bob/Documents"; system("cat *.ini"); my $b = "dummy"; return $b; } 1;

What I tried to do was extend what I have now to create a Config::Tiny ini file. I think the install went well, and judging by how quickly it went, it truly seems tiny:

All tests successful. Files=5, Tests=49, 3 wallclock secs ( 0.06 usr 0.01 sys + 0.45 cusr + 0.10 csys = 0.62 CPU) Result: PASS RSAVAGE/Config-Tiny-2.23.tgz /usr/bin/make test -- OK Running make install Manifying 1 pod document Installing /usr/local/share/perl/5.26.1/Config/Tiny.pm Installing /usr/local/man/man3/Config::Tiny.3pm Appending installation info to /usr/local/lib/x86_64-linux-gnu/perl/5. +26.1/perllocal.pod RSAVAGE/Config-Tiny-2.23.tgz /usr/bin/make install -- OK cpan[2]> q Terminal does not support GetHistory. Lockfile removed. $ man Config::Tiny $ ./1.redact.pl Variable "$config" is not imported at template_stuff/utils2.pm line 61 +. Global symbol "$config" requires explicit package name (did you forget + to declare "my $config"?) at template_stuff/utils2.pm line 61. Compilation failed in require at ./1.redact.pl line 6. BEGIN failed--compilation aborted at ./1.redact.pl line 6.
$ cat config2.pm package config2; use Exporter qw(import); our @EXPORT = qw(%config); our %config = ( my_sftp => { domain => '', username => '', password => '', }, my_github => { email => '', password => '', }, ); 1; $

I don't seem to be sharing is the "our" on the definition of "our %config". Why is my syntax on the config hash clashing with that provided by man Config::Tiny and haukex?


In reply to Re^2: redacting from config hash by Aldebaran
in thread redacting from config hash by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.