Your recollections and posted code check out. Bravo! I consider this a strong result for untangling a windows 10 machine:

#!/usr/bin/perl use warnings; use 5.016; ## File::Find for windows, handling junctions ## https://perlmonks.org/?node_id=11104464 use File::Find; use Cwd; ## https://metacpan.org/pod/Win32API::File use Win32API::File qw'GetFileAttributes :FILE_ATTRIBUTE_'; use File::Basename; my $current = cwd; my $VERBOSE = 1; find( \&pm_beneath, $current, ); say "--------------"; find( \&pm_beneath, "C:/Strawberry", ); sub isjunc { return GetFileAttributes( $_[0] ) & FILE_ATTRIBUTE_REPARSE_POINT; } sub pm_beneath { if (-d) { # junctions show up as TRUE for `-d` if ( isjunc($File::Find::name) ) { # if junction, don't bother creating checking destination direct +ory existence, # and don't try to recurse into it $File::Find::prune = 1; printf( "[%s] %-12s'%s'\n", scalar(localtime), "JUNCTION:", $File::Find::name ) if ($VERBOSE); return; } } my $basename = basename($File::Find::name); return unless $basename =~ /\.pm$/; print "$File::Find::name\n"; my $access_age = -A $basename; print " $basename\n"; printf "access age in days: %.2f\n", $access_age; } __END__
(File::Find) just prints a warning, but otherwise cannot do anything with the junction -- but other than that, it works fine in windows... and even with junctions, it just gives a warning, so it continues to effectively work.

I understand and agree now. The other script I presented in the original post is still ailing:

I got the system command right on this one, but I'm trying to not have to read in a template file to make code tags, so I'm trying to use the fill_in_string method from Text::Template. My imitation of examples is not working:

C:\Users\tblaz\Documents\evelyn>perl 5.monk.tag.pl No such class Q::symbol at 5.monk.tag.pl line 68, near "my Q::symbol" syntax error at 5.monk.tag.pl line 68, near "my Q::symbol =" Execution of 5.monk.tag.pl aborted due to compilation errors. C:\Users\tblaz\Documents\evelyn>

Source that produced this is:

#!/usr/bin/perl -w use 5.011; use Path::Tiny; use POSIX qw(strftime); # initialization that must precede main data structure # User: enter a subdirectory you would like to create # enter a subdirectory of this^^^ for output my $ts = "template_stuff"; my $output = "translations"; ## turning things to Path::Tiny my $abs = path(__FILE__)->absolute; my $path1 = Path::Tiny->cwd; my $path2 = path( $path1, $ts ); say "abs is $abs"; say "path1 is $path1"; say "path2 is $path2"; print "This script will build the above path2. Proceed? (y|n)"; my $prompt = <STDIN>; chomp $prompt; die unless ( $prompt eq "y" ); my $template_file = "1.tags.tmpl"; my $abs_to_template = path( $path2, $template_file )->touchpath; # script params my %vars = ( monk_tags => path( $path2, $template_file ), translations => path( $path2, $output ), book => 'monastery tags ', ); my $rvars = \%vars; my $return1 = write_monk_tags($rvars); say "return1 is $return1"; my $munge = strftime( "%d-%m-%Y-%H-%M-%S", localtime ); $munge .= ".monk.txt"; # use Path::Tiny to create and write to a text in relevant directory my $save_file = path( $vars{$output}, $munge )->touchpath; my $return2 = $save_file->spew_utf8($return1); say "return2 is $return2"; say "created file $save_file"; system( 1, 'C:\Program Files (x86)\Notepad++\notepad++.exe', $save_fil +e ); sub write_monk_tags { use warnings; use 5.011; use Text::Template 'fill_in_string'; my $rvars = shift; my %vars = %$rvars; my $tag_pair = '<{$symbol}></{$symbol}>'; my $return; # User: change these quoted values for different order or tags my @buchstaben = qw/i p c pre readmore b/; for my $i (@buchstaben) { $vars{"symbol"} = $i; print "How many $i tag pairs would you like?: "; my $prompt = <STDIN>; chomp $prompt; while ( $prompt gt 0 ) { my Q::symbol = $i; my $result = fill_in_string( $tag_pair, PACKAGE => Q ); $return = $return . $result; --$prompt; } } return $return; } __END__

The earlier version that goes like this does not compile either:

sub write_monk_tags { use warnings; use 5.011; use Text::Template 'fill_in_string'; my $rvars = shift; my %vars = %$rvars; # User: change these quoted values for different order or tags my @buchstaben = qw/i p c pre readmore b/; for my $i (@buchstaben) { $vars{"symbol"} = $i; print "How many $i tag pairs would you like?: "; my $prompt = <STDIN>; chomp $prompt; while ( $prompt gt 0 ) { my Q::symbol = $i; my $result = fill_in_string(<<'EOM', PACKAGE => Q); <{$symbol}></{$symbol}> EOM; $return = $return . $result; --$prompt; } return $return; }

This syntax draws the same error. Documentation for this method is here: fill_in_string

Can I make a template from a garden variety lexical variable?

Thanks for comments,


In reply to Re^4: getting a few simple scripts to work on windows by Aldebaran
in thread getting a few simple scripts to work on windows 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.