App-Followme
view release on metacpan or search on metacpan
share/clean.pl view on Meta::CPAN
}
}
die "No matching tag for\n" . join("\n", @hold) . "\n" if @hold;
push(@output, @input);
return join('', @output)
}
#----------------------------------------------------------------------
# Create a backup copy of the original file
sub backup_file {
my ($file, $text) = @_;
$file .= '~';
write_file($file, $text);
}
#----------------------------------------------------------------------
# Clean each file by substuting tokens with their patterns
sub clean_files {
my ($patterns, @files) = @_;
foreach my $file (@files) {
my $text = slurp_file($file);
backup_file($file, $text);
my @tags = web_split_at_tags($text);
my $tokens = {next => 0, data => \@tags};
$text = replace_tokens($patterns, $tokens);
$text = add_sections($text, TEMPLATE);
$text = web_substitute_sections($text, {meta => METADATA});
write_file($file, $text);
}
share/flatten.pl view on Meta::CPAN
#----------------------------------------------------------------------
# Alter the files in a folder
sub alter_files {
my ($folder) = @_;
my @files = find_files($folder);
foreach my $file (@files) {
my $text = slurp_file($file);
backup_file($file, $text);
$text = alter_text($text);
write_file($file, $text);
}
return;
}
#----------------------------------------------------------------------
# Alter the file names in a file
share/flatten.pl view on Meta::CPAN
if ($url !~ /:/) {
my @path = split(/\//, $url);
$url = pop(@path);
}
return $url;
}
#----------------------------------------------------------------------
# Create a backup copy of the original file
sub backup_file {
my ($file, $text) = @_;
$file .= '~';
write_file($file, $text);
}
#----------------------------------------------------------------------
# Find files to modify
sub find_files {
share/flatten.pl view on Meta::CPAN
script is run.
=head1 FLAGS
This script supports a single command line flag:
=over 4
=item -r
Before modifying the file the script creates a backup copy whose name is
the same with an appended ~ character. If the -r flag is on the command
line, instead of modifying the files, it restores the original file by
copying the old version over the modified version. This script for
developers of this code and not for end users.
=back
=head1 LICENSE
Copyright (C) Bernie Simon.
( run in 1.363 second using v1.01-cache-2.11-cpan-49f99fa48dc )